register form
This commit is contained in:
1 parent
390a98e961
commit
b5d090cf5e
18 files changed
+349
-46
No files matched your search
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Auth;
|
||||
|
||||
use App\Models\Konto;
|
||||
use Danielebarbaro\LaravelVatEuValidator\Rules\VatNumber;
|
||||
use Filament\Auth\Pages\Register as BaseRegister;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Wizard;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Filament\Schemas\Schema;
|
||||
use Ysfkaya\FilamentPhoneInput\Forms\PhoneInput;
|
||||
|
||||
class Register extends BaseRegister
|
||||
{
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Wizard::make([
|
||||
Step::make('Profile')
|
||||
->icon('lucide-user-plus')
|
||||
->description('Benutzer anlegen.')
|
||||
->schema([
|
||||
$this->getNameFormComponent(),
|
||||
$this->getEmailFormComponent(),
|
||||
$this->getPasswordFormComponent(),
|
||||
$this->getPasswordConfirmationFormComponent(),
|
||||
]),
|
||||
Wizard\Step::make('Konto')
|
||||
// ->columns(4)
|
||||
->icon('lucide-key-square')
|
||||
->description('Mit einem Konto verbinden.')
|
||||
->schema([
|
||||
$this->getKontoFormComponent(),
|
||||
/** OLD */
|
||||
$this->selectKontoFormComponent(),
|
||||
/** NEU */
|
||||
Fieldset::make('Rechnungsdaten')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->schema([
|
||||
$this->getCompanyFormComponent(),
|
||||
$this->getUIDFormComponent(),
|
||||
$this->getPlaceFormComponent(),
|
||||
$this->getPLZFormComponent(),
|
||||
$this->getCountryFormComponent(),
|
||||
$this->getAdresseFormComponent(),
|
||||
$this->getGenderFormComponent(),
|
||||
$this->getFirstNameFormComponent(),
|
||||
$this->getLastNameFormComponent(),
|
||||
$this->getPhoneFormComponent(),
|
||||
$this->getKontoEmailFormComponent(),
|
||||
])->columnSpan(4),
|
||||
|
||||
]),
|
||||
]),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getPhoneFormComponent(): PhoneInput
|
||||
{
|
||||
return PhoneInput::make('phone')
|
||||
->label('Telefon')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->defaultCountry('AT');
|
||||
}
|
||||
|
||||
protected function getCountryFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('country')
|
||||
->label('Land')
|
||||
->placeholder('Österreich')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getKontoEmailFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('konto-email')
|
||||
->label('E-Mail')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getPLZFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('code')
|
||||
->label('Postleitzahl')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getPlaceFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('place')
|
||||
->label('Ort')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getAdresseFormComponent(): Textarea
|
||||
{
|
||||
return Textarea::make('address')
|
||||
->label('Adresse')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getFirstNameFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('first_name')
|
||||
->label('Vorname')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getLastNameFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('last_name')
|
||||
->label('Nachname')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getUIDFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('uid_number')
|
||||
->label('UID Nummer')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->rules([new VatNumber])
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getCompanyFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('company')
|
||||
->label('Firma')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getRoleFormComponent(): Select
|
||||
{
|
||||
return Select::make('role')
|
||||
->options([
|
||||
'gutachter' => 'Gutachter',
|
||||
'super_admin' => 'Administrator',
|
||||
])
|
||||
->default('gutachter')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getGenderFormComponent(): Select
|
||||
{
|
||||
return Select::make('gender')
|
||||
->columnSpan(2)
|
||||
->label('Geschlecht')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getKontoFormComponent(): Select
|
||||
{
|
||||
return Select::make('konto')
|
||||
->columnSpan(4)
|
||||
->label('Registriermodus')
|
||||
->prefixIcon('lucide-key-square')
|
||||
->prefixIconColor('primary')
|
||||
->aboveLabel([
|
||||
'Bitte wählen Sie ein bestehendes Konto oder erstellen Sie ein neues. Eine Registrierung bei einem bestehenden Konto muß vom Kontoinhaber bestätigt werden.',
|
||||
])
|
||||
->options([
|
||||
'old' => 'Mit einem bestehenden Konto verbinden',
|
||||
'new' => 'Ein neues Konto erstellen',
|
||||
])
|
||||
->live()
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function selectKontoFormComponent(): Select
|
||||
{
|
||||
return Select::make('konto_id')
|
||||
->columnSpan(4)
|
||||
->label('Konto auswählen')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'old')
|
||||
->options(Konto::query()->pluck('company', 'id'))
|
||||
->searchable()
|
||||
->required();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user