'bool', 'is_system' => 'boolean', 'quota_mb'=>'int', 'last_login_at'=>'datetime', ]; public function domain(): BelongsTo { return $this->belongsTo(Domain::class); } public function setPasswordAttribute(string $plain): void { // optional: allow 'password' virtual attribute $this->attributes['password_hash'] = password_hash($plain, PASSWORD_BCRYPT); } // Ausgabe: vollständige Adresse public function getEmailAttribute(): string { return "{$this->local_part}@{$this->domain->name}"; } public function getAddressAttribute(): string { $local = (string)($this->attributes['localpart'] ?? $this->localpart ?? ''); // bevorzugt den in Queries selektierten Alias `dom`, sonst Relation, sonst Roh-Attribut $dom = (string)( $this->attributes['dom'] ?? ($this->relationLoaded('domain') ? ($this->domain->domain ?? '') : '') ?? ($this->attributes['domain'] ?? '') ); if ($local !== '' && $dom !== '') return "{$local}@{$dom}"; if (($this->attributes['email'] ?? null) !== null) return (string)$this->attributes['email']; return $dom !== '' ? "@{$dom}" : ''; } // Scopes public function scopeActive($q) { return $q->where('is_active', true); } public function scopeSystem($q) { return $q->where('is_system', true); } public function scopeByEmail($q, string $email) { return $q->where('email', $email); } }