72 lines
2.2 KiB
PHP
72 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use Filament\Auth\Pages\Register;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Schemas\Schema;
|
|
use Illuminate\Contracts\Support\Htmlable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class CustomRegistration extends Register
|
|
{
|
|
public function getHeading(): string|Htmlable
|
|
{
|
|
return '';
|
|
}
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('name')
|
|
->label('Nama')
|
|
->placeholder('John Doe')
|
|
->autocomplete(false)
|
|
->autofocus()
|
|
->required()
|
|
->maxLength(100),
|
|
|
|
TextInput::make('email')
|
|
->label('Alamat Surel')
|
|
->placeholder('johndoe@example.com')
|
|
->autocomplete(false)
|
|
->required()
|
|
->maxLength(254)
|
|
->unique()
|
|
->email(),
|
|
|
|
TextInput::make('username')
|
|
->label('Nama Pengguna')
|
|
->placeholder('johndoe')
|
|
->autocomplete(false)
|
|
->required()
|
|
->minLength(5)
|
|
->maxLength(20)
|
|
->regex('/^[a-zA-Z0-9_.-]+$/')
|
|
->unique(),
|
|
|
|
TextInput::make('password')
|
|
->label('Kata Sandi')
|
|
->password()
|
|
->revealable(filament()->arePasswordsRevealable())
|
|
->required()
|
|
->rule(Password::default())
|
|
->autocomplete(false)
|
|
->dehydrated(fn ($state): bool => filled($state))
|
|
->dehydrateStateUsing(fn ($state): string => Hash::make($state))
|
|
->placeholder('********'),
|
|
]);
|
|
}
|
|
|
|
protected function handleRegistration(array $data): Model
|
|
{
|
|
$user = $this->getUserModel()::create($data);
|
|
$user->assignRole('Perusahaan');
|
|
|
|
return $user;
|
|
}
|
|
}
|