api/app/Filament/Resources/Users/Schemas/UserForm.php

54 lines
1.8 KiB
PHP

<?php
namespace App\Filament\Resources\Users\Schemas;
use App\Enums\UserRole;
use Illuminate\Support\Facades\Hash;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
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(),
TextInput::make('avatar_uri'),
TextInput::make('level')
->required()
->numeric()
->default(1),
]);
}
}