46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Users\Schemas;
|
|
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Schemas\Schema;
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
class UserForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('name')
|
|
->label(__('app.name'))
|
|
->required()
|
|
->maxLength(255),
|
|
|
|
TextInput::make('email')
|
|
->label(__('app.email'))
|
|
->email()
|
|
->required()
|
|
->maxLength(255)
|
|
->unique(ignoreRecord: true),
|
|
|
|
TextInput::make('password')
|
|
->label(__('app.password'))
|
|
->password()
|
|
->revealable()
|
|
->required(fn (string $operation): bool => $operation === 'create')
|
|
->dehydrateStateUsing(fn (?string $state): ?string => filled($state) ? bcrypt($state) : null)
|
|
->dehydrated(fn (?string $state): bool => filled($state))
|
|
->maxLength(255)
|
|
->columnSpanFull(),
|
|
|
|
Select::make('role')
|
|
->label(__('app.role'))
|
|
->options(Role::pluck('name', 'name')->toArray())
|
|
->required()
|
|
->searchable(),
|
|
]);
|
|
}
|
|
}
|