| Total Complexity | 6 |
| Total Lines | 74 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class MongoDatabaseNotification extends Model |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Indicates if the IDs are auto-incrementing. |
||
| 19 | * |
||
| 20 | * @var bool |
||
| 21 | */ |
||
| 22 | public $incrementing = false; |
||
| 23 | /** |
||
| 24 | * The table associated with the model. |
||
| 25 | * |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $collection = 'notifications'; |
||
| 29 | /** |
||
| 30 | * The guarded attributes on the model. |
||
| 31 | * |
||
| 32 | * @var array |
||
| 33 | */ |
||
| 34 | protected $guarded = []; |
||
| 35 | /** |
||
| 36 | * The attributes that should be cast to native types. |
||
| 37 | * |
||
| 38 | * @var array |
||
| 39 | */ |
||
| 40 | protected $casts = [ |
||
| 41 | 'data' => 'array', |
||
| 42 | 'read_at' => 'datetime', |
||
| 43 | ]; |
||
| 44 | /** |
||
| 45 | * Get the notifiable entity that the notification belongs to. |
||
| 46 | */ |
||
| 47 | public function notifiable() |
||
| 50 | } |
||
| 51 | /** |
||
| 52 | * Mark the notification as read. |
||
| 53 | * |
||
| 54 | * @return void |
||
| 55 | */ |
||
| 56 | public function markAsRead() |
||
| 57 | { |
||
| 58 | if (is_null($this->read_at)) { |
||
|
|
|||
| 59 | $this->forceFill(['read_at' => $this->freshTimestamp()])->save(); |
||
| 60 | } |
||
| 61 | } |
||
| 62 | /** |
||
| 63 | * Determine if a notification has been read. |
||
| 64 | * |
||
| 65 | * @return bool |
||
| 66 | */ |
||
| 67 | public function read() |
||
| 68 | { |
||
| 69 | return $this->read_at !== null; |
||
| 70 | } |
||
| 71 | /** |
||
| 72 | * Determine if a notification has not been read. |
||
| 73 | * |
||
| 74 | * @return bool |
||
| 75 | */ |
||
| 76 | public function unread() |
||
| 77 | { |
||
| 78 | return $this->read_at === null; |
||
| 79 | } |
||
| 80 | /** |
||
| 81 | * Create a new database notification collection instance. |
||
| 82 | * |
||
| 83 | * @param array $models |
||
| 84 | * @return \Illuminate\Notifications\DatabaseNotificationCollection |
||
| 85 | */ |
||
| 86 | public function newCollection(array $models = []) |
||
| 89 | } |
||
| 90 | } |
||
| 91 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.