46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Users\Schemas;
|
|
|
|
use App\Models\Bookmaker;
|
|
use App\Models\Client;
|
|
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('name')
|
|
->required(),
|
|
TextInput::make('email')
|
|
->label('Email address')
|
|
->email()
|
|
->required(),
|
|
Select::make('client_id')
|
|
->relationship('client', 'name')
|
|
->preload(),
|
|
Select::make('bookmaker_id')
|
|
->label('Active Bookmaker')
|
|
->options(function () {
|
|
$bookmaker = Client::where('id', auth()->user()->client_id)->value('bookmaker');
|
|
|
|
return Bookmaker::query()->whereIn('id', $bookmaker)->pluck('name', 'id');
|
|
})
|
|
->preload(),
|
|
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(),
|
|
]);
|
|
}
|
|
}
|