- Sprache je Benutzer (users.locale), Middleware SetLocale, Auswahl unter Einstellungen → Darstellung; angebotene Sprachen in config/app.php - Übersetzungen über Laravel Lang (lang/de.json, lang/de/*.php), Seitentitel aus #[Title] werden übersetzt - Eigene Texte und Korrekturen in lang/project/de.json, übernommen mit `artisan lang:apply-project` (überstehen `lang:update`) - Tests: jede im Code verwendete Übersetzung ist vorhanden, eigene Übersetzungen sind übernommen, Sprachwahl und Standardsprache; SecurityTest prüft Texte sprachunabhängig über __() - lang/ von Pint ausgenommen (erzeugte Dateien) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Database\Factories\UserFactory;
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Str;
|
|
use Laravel\Fortify\Contracts\PasskeyUser;
|
|
use Laravel\Fortify\PasskeyAuthenticatable;
|
|
use Laravel\Fortify\TwoFactorAuthenticatable;
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property string $email
|
|
* @property string|null $locale
|
|
* @property Carbon|null $email_verified_at
|
|
* @property string $password
|
|
* @property string|null $two_factor_secret
|
|
* @property string|null $two_factor_recovery_codes
|
|
* @property Carbon|null $two_factor_confirmed_at
|
|
* @property string|null $remember_token
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
*/
|
|
#[Fillable(['name', 'email', 'password', 'locale'])]
|
|
#[Hidden(['password', 'two_factor_secret', 'two_factor_recovery_codes', 'remember_token'])]
|
|
class User extends Authenticatable implements MustVerifyEmail, PasskeyUser
|
|
{
|
|
/** @use HasFactory<UserFactory> */
|
|
use HasFactory, HasRoles, Notifiable, PasskeyAuthenticatable, TwoFactorAuthenticatable;
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the user's initials
|
|
*/
|
|
public function initials(): string
|
|
{
|
|
$initials = Str::initials($this->name, true);
|
|
|
|
return Str::length($initials) > 1
|
|
? Str::substr($initials, 0, 1).Str::substr($initials, -1)
|
|
: $initials;
|
|
}
|
|
}
|