55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Users\Schemas;
|
|
|
|
use App\Enums\UserRole;
|
|
use Filament\Forms\Components\DateTimePicker;
|
|
use Filament\Forms\Components\FileUpload;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Schemas\Schema;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class UserForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('username')
|
|
->required(),
|
|
TextInput::make('email')
|
|
->label('Email address')
|
|
->email()
|
|
->required(),
|
|
TextInput::make('xp')
|
|
->required()
|
|
->numeric()
|
|
->default(0),
|
|
TextInput::make('participations')
|
|
->required()
|
|
->numeric()
|
|
->default(0),
|
|
TextInput::make('victories')
|
|
->required()
|
|
->numeric()
|
|
->default(0),
|
|
DateTimePicker::make('email_verified_at'),
|
|
TextInput::make('password')
|
|
->password()
|
|
->dehydrateStateUsing(fn ($state) => Hash::make($state))
|
|
->dehydrated(fn ($state) => filled($state))
|
|
->required(fn (string $operation): bool => $operation === 'create'),
|
|
Select::make('role')
|
|
->options(UserRole::class)
|
|
->default('user')
|
|
->required(),
|
|
FileUpload::make('avatar_uri')
|
|
->image()
|
|
->avatar()
|
|
->disk('public')
|
|
->directory('avatars'),
|
|
]);
|
|
}
|
|
}
|