*/ use BelongsToTenant, HasFactory; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'kind' => InboxMessageKind::class, 'notified_at' => 'immutable_datetime', 'last_seen_at' => 'immutable_datetime', 'read_at' => 'immutable_datetime', ]; } /** * @return BelongsTo */ public function property(): BelongsTo { return $this->belongsTo(Property::class); } /** * @return BelongsTo */ public function channel(): BelongsTo { return $this->belongsTo(Channel::class); } public function isRead(): bool { return $this->read_at !== null; } /** * @param Builder $query * @return Builder */ #[Scope] protected function unread(Builder $query): Builder { return $query->whereNull('read_at'); } }