'array', 'read_at' => 'datetime', ]; public function user() { return $this->belongsTo(User::class); } public function isRead() { return $this->read_at !== null; } public function scopeUnread($query) { return $query->whereNull('read_at'); } public function toInboxArray() { return [ 'id' => $this->id, 'type' => $this->type, 'title' => $this->title, 'body' => $this->body, 'url' => $this->url, 'read_at' => $this->read_at ? $this->read_at->toIso8601String() : null, 'created_at' => $this->created_at ? $this->created_at->toIso8601String() : null, 'created_at_human' => $this->created_at ? $this->created_at->diffForHumans() : null, ]; } }