*/ protected function casts(): array { return [ 'classification' => CompanyAddressClass::class, 'manual_classification' => CompanyAddressClass::class, 'classified_at' => 'datetime', ]; } /** * Die Klasse, die gilt: die von Hand gesetzte, sonst die berechnete. Wer * über eine Adresse entscheidet, fragt IMMER hier — nie die berechnete * Spalte direkt. */ public function effectiveClassification(): CompanyAddressClass { return $this->manual_classification ?? $this->classification; } public function isMergeable(): bool { return $this->effectiveClassification()->isMergeable(); } public static function forEmail(?string $email): ?self { $key = Company::emailKey($email); if ($key === null) { return null; } return static::query()->where('email', $key)->first(); } }