30 lines
		
	
	
		
			594 B
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			594 B
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| namespace App;
 | |
| 
 | |
| use App\Nami\HasNamiField;
 | |
| use Illuminate\Database\Eloquent\Factories\HasFactory;
 | |
| use Illuminate\Database\Eloquent\Model;
 | |
| 
 | |
| class Gender extends Model
 | |
| {
 | |
|     use HasNamiField;
 | |
|     use HasFactory;
 | |
| 
 | |
|     public $fillable = ['name', 'nami_id'];
 | |
| 
 | |
|     public function getSalutationAttribute(): string
 | |
|     {
 | |
|         return match ($this->name) {
 | |
|             'Männlich' => 'Herr',
 | |
|             'Weiblich' => 'Frau',
 | |
|             default => ''
 | |
|         };
 | |
|     }
 | |
| 
 | |
|     public static function fromString(string $title): self
 | |
|     {
 | |
|         return self::firstWhere('name', $title);
 | |
|     }
 | |
| }
 |