*/ use HasFactory, SoftDeletes; protected $fillable = [ 'domain_hash', 'name', 'allowed_types', 'is_active', 'is_archived', ]; protected function casts(): array { return [ 'allowed_types' => 'array', 'is_active' => 'boolean', 'is_archived' => 'boolean', ]; } protected static function booted(): void { static::creating(function (Domain $domain) { if (empty($domain->domain_hash)) { $domain->domain_hash = bin2hex(random_bytes(32)); } }); } public function mailboxes() { return $this->hasMany(Mailbox::class, 'domain_hash', 'domain_hash'); } }