'boolean', 'active' => 'boolean', 'last_verified_at' => 'datetime', ]; } public static function findByKey(string $key): ?self { return static::query()->where('key', $key)->first(); } /** Plaintext in, ciphertext to the column. */ public function setPasswordAttribute(?string $value): void { $this->attributes['password'] = ($value === null || $value === '') ? null : app(SecretCipher::class)->encrypt($value); } /** Ciphertext from the column, plaintext out. */ public function getPasswordAttribute(?string $value): ?string { return ($value === null || $value === '') ? null : app(SecretCipher::class)->decrypt($value); } /** The SMTP user: an explicit one, or the address itself. */ public function smtpUsername(): string { return $this->username !== null && $this->username !== '' ? $this->username : $this->address; } /** Enough to send with: an address and a password. */ public function isConfigured(): bool { return $this->active && $this->address !== '' && $this->getRawOriginal('password') !== null; } }