'array', 'answers' => 'array', 'notes' => 'array', 'notify_failed' => 'boolean', 'subject_id' => 'integer', 'opened_at' => 'datetime', 'handled_at' => 'datetime', 'notified_at' => 'datetime', ]; } /** The real requests that still wait for the owner. */ public function scopeWaiting(Builder $query): void { $query->where('folder', self::INBOX)->whereNull('handled_at'); } /** The real requests that were handled. */ public function scopeHandled(Builder $query): void { $query->where('folder', self::INBOX)->whereNotNull('handled_at'); } /** What the owner reads for the kind: a name from `manager.leads.kinds`, else the kind itself. */ public function kindLabel(): string { return (string) __((string) (config('manager.leads.kinds')[$this->kind] ?? ucfirst($this->kind))); } /** What it is about, in a few words: the subject the site gave, or the kind of request. */ public function aboutLine(): string { return $this->subject !== null && $this->subject !== '' ? $this->subject : $this->kindLabel(); } /** The text as it is compared with earlier ones: lowercase, without the spaces and marks around the words. */ public static function hashOf(?string $message): ?string { $text = trim(preg_replace('/[^\p{L}\p{N}]+/u', ' ', mb_strtolower((string) $message)) ?? ''); // A few words ("call me") are the same for many honest people. return mb_strlen($text) < 40 ? null : hash('sha256', $text); } }