| Total Complexity | 5 |
| Total Lines | 75 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 13 | class UserNotification extends Model |
||
| 14 | { |
||
| 15 | use HasFactory; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The "booting" method of the model. |
||
| 19 | * |
||
| 20 | * @return void |
||
| 21 | */ |
||
| 22 | protected static function boot() |
||
| 23 | { |
||
| 24 | parent::boot(); |
||
| 25 | |||
| 26 | // Query scopes |
||
| 27 | static::addGlobalScope(new CreatedOrderScope()); |
||
| 28 | } |
||
| 29 | |||
| 30 | protected $table = 'user_notification'; |
||
| 31 | protected $primaryKey = 'user_notification_id'; |
||
| 32 | |||
| 33 | protected $fillable = [ |
||
| 34 | 'user_notification_id', |
||
| 35 | 'user_id', |
||
| 36 | 'type', |
||
| 37 | ]; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * The attributes that should type cast. |
||
| 41 | * |
||
| 42 | * @var array |
||
| 43 | */ |
||
| 44 | protected $casts = [ |
||
| 45 | 'user_id' => 'int', |
||
| 46 | ]; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Create a new factory instance for the model. |
||
| 50 | * |
||
| 51 | * @return UserNotificationFactory |
||
| 52 | */ |
||
| 53 | protected static function newFactory(): UserNotificationFactory |
||
| 54 | { |
||
| 55 | return new UserNotificationFactory(); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Query Builder. |
||
| 60 | * |
||
| 61 | * @param $query |
||
| 62 | * |
||
| 63 | * @return UserNotificationBuilder |
||
| 64 | */ |
||
| 65 | public function newEloquentBuilder($query) |
||
| 66 | { |
||
| 67 | return new UserNotificationBuilder($query); |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Custom query Builder. |
||
| 72 | * |
||
| 73 | * @return UserNotificationBuilder|Builder |
||
| 74 | */ |
||
| 75 | public static function query(): UserNotificationBuilder |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * User model this notification subscription belongs to. |
||
| 82 | * |
||
| 83 | * @return BelongsTo |
||
| 84 | */ |
||
| 85 | public function user() |
||
| 88 | } |
||
| 89 | } |
||
| 90 |