'array', 'received_at' => 'datetime', 'read_at' => 'datetime', 'archived_at' => 'datetime', ]; } public function customer(): BelongsTo { return $this->belongsTo(Customer::class); } public function supportRequest(): BelongsTo { return $this->belongsTo(SupportRequest::class); } /** Still in the inbox, i.e. not put away. */ public function scopeOpen(Builder $query): Builder { return $query->whereNull('archived_at'); } /** * From an address nobody recognises. * * Not an error state: it is a new enquiry, or a customer writing from their * private address. The mail an operator must not miss is exactly this one. */ public function isUnassigned(): bool { return $this->customer_id === null; } public function hasAttachments(): bool { return ! empty($this->attachments); } }