2025-10-23 11:41:56 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Filament\Resources\Users\Schemas;
|
|
|
|
|
|
2026-02-03 11:57:36 +01:00
|
|
|
use App\Models\User;
|
2025-10-23 11:41:56 +02:00
|
|
|
use Filament\Forms\Components\DateTimePicker;
|
2026-02-03 11:57:36 +01:00
|
|
|
use Filament\Forms\Components\Select;
|
2025-10-23 11:41:56 +02:00
|
|
|
use Filament\Forms\Components\TextInput;
|
|
|
|
|
use Filament\Schemas\Schema;
|
2026-02-03 11:57:36 +01:00
|
|
|
use Illuminate\Support\Facades\Hash;
|
2025-10-23 11:41:56 +02:00
|
|
|
|
|
|
|
|
class UserForm
|
|
|
|
|
{
|
|
|
|
|
public static function configure(Schema $schema): Schema
|
|
|
|
|
{
|
|
|
|
|
return $schema
|
|
|
|
|
->components([
|
|
|
|
|
TextInput::make('name')
|
2026-02-03 11:57:36 +01:00
|
|
|
->label(User::getAttributeLabel('name'))
|
2025-10-23 11:41:56 +02:00
|
|
|
->required(),
|
|
|
|
|
TextInput::make('email')
|
2026-02-03 11:57:36 +01:00
|
|
|
->label(User::getAttributeLabel('email'))
|
2025-10-23 11:41:56 +02:00
|
|
|
->label('Email address')
|
|
|
|
|
->email()
|
|
|
|
|
->required(),
|
2026-02-03 11:57:36 +01:00
|
|
|
DateTimePicker::make('email_verified_at')
|
|
|
|
|
->label(User::getAttributeLabel('email_verified_at')),
|
2025-10-23 11:41:56 +02:00
|
|
|
TextInput::make('password')
|
2026-02-03 11:57:36 +01:00
|
|
|
->label(User::getAttributeLabel('password'))
|
2025-10-23 11:41:56 +02:00
|
|
|
->password()
|
2026-02-03 11:57:36 +01:00
|
|
|
->dehydrated(fn ($state) => filled($state))
|
|
|
|
|
->dehydrateStateUsing(fn ($state) => Hash::make($state)),
|
|
|
|
|
Select::make('role')
|
|
|
|
|
->label(User::getAttributeLabel('role'))
|
|
|
|
|
->relationship('roles', 'name')
|
|
|
|
|
->multiple()
|
|
|
|
|
->preload()
|
|
|
|
|
->searchable()
|
2025-10-23 11:41:56 +02:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|