wip
This commit is contained in:
1 parent
368af4b565
commit
aba3a87745
9 files changed
+142
-95
No files matched your search
@@ -4,9 +4,13 @@ namespace App\Filament\Resources\Users\Schemas;
|
||||
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\Client;
|
||||
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
|
||||
{
|
||||
@@ -14,40 +18,74 @@ class UserForm
|
||||
{
|
||||
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('roles')
|
||||
->label('Rollen')
|
||||
->prefixIcon('phosphor-gear')
|
||||
->aboveContent('Only visible for super_admin')
|
||||
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('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(function () {
|
||||
$bookmaker = Client::where('id', auth()->user()->client_id)->value('bookmaker');
|
||||
|
||||
return Bookmaker::query()->whereIn('id', $bookmaker)->pluck('name', 'id');
|
||||
})
|
||||
->preload(),
|
||||
Select::make('provider_id')
|
||||
->relationship('provider', 'name')
|
||||
->preload(),
|
||||
]),
|
||||
Section::make('Authorisations')
|
||||
->visible(fn () => auth()->user()->hasRole('super_admin'))
|
||||
->relationship('roles', 'name')
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
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('partner_bookmaker_id')
|
||||
->label('Partner Bookmaker')
|
||||
->options(function () {
|
||||
$bookmaker = Client::where('id', auth()->user()->client_id)->value('bookmaker');
|
||||
|
||||
return Bookmaker::query()->whereIn('id', $bookmaker)->pluck('name', 'id');
|
||||
})
|
||||
->preload(),
|
||||
->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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user