2020-04-12 00:26:44 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
2021-11-17 22:32:52 +01:00
|
|
|
use App\Nami\HasNamiField;
|
2024-09-22 17:32:29 +02:00
|
|
|
use Database\Factories\GenderFactory;
|
2022-08-12 22:07:59 +02:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2020-04-12 00:26:44 +02:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Gender extends Model
|
|
|
|
{
|
2021-11-17 22:32:52 +01:00
|
|
|
use HasNamiField;
|
2024-09-22 17:32:29 +02:00
|
|
|
|
|
|
|
/** @use HasFactory<GenderFactory> */
|
2022-08-12 22:07:59 +02:00
|
|
|
use HasFactory;
|
2021-11-17 22:32:52 +01:00
|
|
|
|
2021-04-11 17:02:49 +02:00
|
|
|
public $fillable = ['name', 'nami_id'];
|
2022-11-19 00:21:58 +01:00
|
|
|
|
|
|
|
public function getSalutationAttribute(): string
|
|
|
|
{
|
|
|
|
return match ($this->name) {
|
|
|
|
'Männlich' => 'Herr',
|
|
|
|
'Weiblich' => 'Frau',
|
|
|
|
default => ''
|
|
|
|
};
|
|
|
|
}
|
2023-05-17 00:22:43 +02:00
|
|
|
|
2024-12-13 01:59:09 +01:00
|
|
|
public function getShortAttribute(): string
|
|
|
|
{
|
|
|
|
return match ($this->name) {
|
|
|
|
'Männlich' => 'm',
|
|
|
|
'Weiblich' => 'w',
|
|
|
|
default => ''
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-05-17 00:22:43 +02:00
|
|
|
public static function fromString(string $title): self
|
|
|
|
{
|
|
|
|
return self::firstWhere('name', $title);
|
|
|
|
}
|
2020-04-12 00:26:44 +02:00
|
|
|
}
|