Notification.php 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\SoftDeletes;
  6. /**
  7. * @property int $id
  8. * @property string $origin_table
  9. * @property int $origin_id
  10. * @property int|null $unit_id
  11. * @property int|null $franchisee_id
  12. * @property string $notification_type
  13. * @property string $title
  14. * @property string $message
  15. * @property string|null $url
  16. * @property string|null $action_text
  17. * @property string $priority
  18. * @property \Illuminate\Support\Carbon|null $expires_at
  19. * @property int|null $created_by_user_id
  20. * @property \Illuminate\Support\Carbon|null $created_at
  21. * @property \Illuminate\Support\Carbon|null $updated_at
  22. * @property \Illuminate\Support\Carbon|null $deleted_at
  23. * @property-read \App\Models\User|null $creator
  24. * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\NotificationRecipient> $recipients
  25. * @property-read int|null $recipients_count
  26. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification newModelQuery()
  27. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification newQuery()
  28. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification onlyTrashed()
  29. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification query()
  30. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereActionText($value)
  31. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereCreatedAt($value)
  32. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereCreatedByUserId($value)
  33. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereDeletedAt($value)
  34. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereExpiresAt($value)
  35. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereFranchiseeId($value)
  36. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereId($value)
  37. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereMessage($value)
  38. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereNotificationType($value)
  39. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereOriginId($value)
  40. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereOriginTable($value)
  41. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification wherePriority($value)
  42. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereTitle($value)
  43. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereUnitId($value)
  44. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereUpdatedAt($value)
  45. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereUrl($value)
  46. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification withTrashed(bool $withTrashed = true)
  47. * @method static \Illuminate\Database\Eloquent\Builder<static>|Notification withoutTrashed()
  48. * @mixin \Eloquent
  49. */
  50. class Notification extends Model
  51. {
  52. use HasFactory, SoftDeletes;
  53. protected $table = 'notifications';
  54. protected $guarded = [
  55. 'id', // Add more fields that shouldn't be edited here
  56. ];
  57. protected $casts = [
  58. 'expires_at' => 'datetime',
  59. 'created_at' => 'datetime',
  60. 'updated_at' => 'datetime',
  61. 'deleted_at' => 'datetime',
  62. ];
  63. // Relationships
  64. public function recipients(): \Illuminate\Database\Eloquent\Relations\HasMany
  65. {
  66. return $this->hasMany(NotificationRecipient::class, 'notification_id');
  67. }
  68. public function creator(): \Illuminate\Database\Eloquent\Relations\BelongsTo
  69. {
  70. return $this->belongsTo(User::class, 'created_by_user_id');
  71. }
  72. // Business Logic Methods
  73. // Custom Finders
  74. // Query Scopes
  75. }