Skip to content

Commit

Permalink
Add missing user timezone stuff (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 authored Jun 29, 2024
1 parent 82c0568 commit 133b94a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function rules(array $rules = null): array
'username',
'password',
'language',
'timezone',
'root_admin',
])->toArray();

Expand Down
6 changes: 6 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Exceptions\DisplayException;
use App\Rules\Username;
use App\Facades\Activity;
use DateTimeZone;
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
use Filament\Models\Contracts\HasName;
Expand Down Expand Up @@ -38,6 +39,7 @@
* @property string $password
* @property string|null $remember_token
* @property string $language
* @property string $timezone
* @property bool $root_admin
* @property bool $use_totp
* @property string|null $totp_secret
Expand Down Expand Up @@ -70,6 +72,7 @@
* @method static Builder|User whereGravatar($value)
* @method static Builder|User whereId($value)
* @method static Builder|User whereLanguage($value)
* @method static Builder|User whereTimezone($value)
* @method static Builder|User whereNameFirst($value)
* @method static Builder|User whereNameLast($value)
* @method static Builder|User wherePassword($value)
Expand Down Expand Up @@ -144,6 +147,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
'external_id' => null,
'root_admin' => false,
'language' => 'en',
'timezone' => 'UTC',
'use_totp' => false,
'totp_secret' => null,
'name_first' => '',
Expand All @@ -164,6 +168,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
'password' => 'sometimes|nullable|string',
'root_admin' => 'boolean',
'language' => 'string',
'timezone' => 'string',
'use_totp' => 'boolean',
'totp_secret' => 'nullable|string',
'oauth' => 'array|nullable',
Expand Down Expand Up @@ -210,6 +215,7 @@ public static function getRules(): array
$rules = parent::getRules();

$rules['language'][] = new In(array_keys((new self())->getAvailableLanguages()));
$rules['timezone'][] = new In(array_values(DateTimeZone::listIdentifiers()));
$rules['username'][] = new Username();

return $rules;
Expand Down

0 comments on commit 133b94a

Please sign in to comment.