*/ use HasFactory, HasUuids; /** * @var list */ protected $fillable = [ 'user_id', 'workspace_id', 'type', 'channel', 'title', 'body', 'data', 'read_at', 'archived_at', ]; /** * @return array */ protected function casts(): array { return [ 'type' => Type::class, 'channel' => Channel::class, 'data' => 'array', 'read_at' => 'datetime', 'archived_at' => 'datetime', ]; } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function workspace(): BelongsTo { return $this->belongsTo(Workspace::class); } public function markAsRead(): void { $this->update(['read_at' => now()]); } public function archive(): void { $this->update(['archived_at' => now()]); } public function isRead(): bool { return $this->read_at !== null; } public function isArchived(): bool { return $this->archived_at !== null; } }