Add user's locale preference

This commit is contained in:
Bubka 2024-04-15 21:20:36 +02:00
parent 44d7328d6c
commit 086dd241d2

View File

@ -6,6 +6,7 @@
use App\Models\Traits\WebAuthnManageCredentials;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Contracts\Translation\HasLocalePreference;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@ -41,7 +42,7 @@
* @property-read \Illuminate\Database\Eloquent\Collection|\Laragear\WebAuthn\Models\WebAuthnCredential[] $webAuthnCredentials
* @property-read int|null $web_authn_credentials_count
*/
class User extends Authenticatable implements WebAuthnAuthenticatable
class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthenticatable
{
use AuthenticationLoggable;
use HasApiTokens, HasFactory, Notifiable;
@ -86,6 +87,14 @@ class User extends Authenticatable implements WebAuthnAuthenticatable
'demoting',
];
/**
* Get the user's preferred locale.
*/
public function preferredLocale() : string
{
return strval($this->preferences['lang']);
}
/**
* Scope a query to only include admin users.
*