Files
nuhodds_fi4/app/Filament/Resources/Users/Schemas/UserForm.php
T
2026-02-04 12:47:48 +01:00

86 lines
3.6 KiB
PHP

<?php
namespace App\Filament\Resources\Users\Schemas;
use App\Models\Bookmaker;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules\Password;
class UserForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Hidden::make('email_verified_at')->default(now()),
Section::make('User Details')
->columnSpanFull()
->columns(2)
->schema([
TextInput::make('name')
->columns(1)
->required(),
TextInput::make('email')
->label('Email address')
->email()
->required(),
TextInput::make('password')
->password()
->revealable()
->dehydrated(fn ($state): bool => filled($state))
->dehydrateStateUsing(fn ($state): string => Hash::make($state))
->same('password_confirmation')
->rule(Password::min(8)
->mixedCase()
->numbers()
->symbols()
->uncompromised())
->label('Password'),
TextInput::make('password_confirmation')
->password()
->dehydrated(false)
->same('password')
->revealable(),
]),
Section::make('Bookmaker Configuration')
->columnSpanFull()
->columns(2)
->schema([
Select::make('client_id')
->relationship('client', 'name')
->preload(),
Select::make('provider_id')
->relationship('provider', 'name')
->preload(),
Select::make('bookmaker_id')
->label('Active Bookmaker')
->options(fn () => Bookmaker::query()->where('is_client', 1)->pluck('name', 'id'))
->preload(),
Select::make('partner_bookmaker_id')
->label('Partner Bookmaker')
->options(fn () => Bookmaker::query()->where('is_client', 1)->pluck('name', 'id'))
->preload(),
]),
Section::make('Authorisations')
->visible(fn () => auth()->user()->hasRole('super_admin'))
->columnSpanFull()
->schema([
Select::make('roles')
->label('Rollen')
->prefixIcon('phosphor-gear')
->aboveContent('Only visible for super_admin')
->visible(fn () => auth()->user()->hasRole('super_admin'))
->relationship('roles', 'name')
->multiple()
->preload()
->searchable(),
]),
]);
}
}