217 lines
7.8 KiB
PHP
217 lines
7.8 KiB
PHP
<?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\Checkbox;
|
|
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\View;
|
|
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->getKontoModusFormComponent(),
|
|
/** OLD */
|
|
$this->getKontoFormComponent(),
|
|
/** NEU */
|
|
Fieldset::make('Rechnungsdaten')
|
|
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
|
->schema([
|
|
$this->getCompanyFormComponent(),
|
|
$this->getUIDFormComponent(),
|
|
$this->getLocationFormComponent(),
|
|
$this->getPLZFormComponent(),
|
|
$this->getCountryFormComponent(),
|
|
$this->getAdresseFormComponent(),
|
|
$this->getGenderFormComponent(),
|
|
$this->getFirstNameFormComponent(),
|
|
$this->getLastNameFormComponent(),
|
|
$this->getKontoEmailFormComponent(),
|
|
$this->getPhoneFormComponent(),
|
|
])->columnSpan(4),
|
|
|
|
]),
|
|
Wizard\Step::make('AGB')
|
|
->icon('lucide-key-square')
|
|
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
|
->description(' Allgemein Geschäftsbedignugen')
|
|
->schema([
|
|
Fieldset::make('Bitte lesen und akzeptieren Sie die allgemeinen Geschäftsbedignungen um die Registrierung abzuschließen.')
|
|
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
|
->schema([
|
|
$this->getABGFormComponent(),
|
|
])->columnSpan(4),
|
|
|
|
View::make('pages.agb'),
|
|
]),
|
|
]),
|
|
|
|
]);
|
|
}
|
|
|
|
protected function getABGFormComponent(): Checkbox
|
|
{
|
|
return Checkbox::make('agb_akzeptiert')
|
|
->label('ABG akzeptieren')
|
|
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
|
->required();
|
|
}
|
|
|
|
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')
|
|
->default('Österreich')
|
|
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
|
->required();
|
|
}
|
|
|
|
protected function getKontoEmailFormComponent(): TextInput
|
|
{
|
|
return TextInput::make('kontoemail')
|
|
->label('E-Mail')
|
|
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
|
->unique(table: Konto::class)
|
|
->required();
|
|
}
|
|
|
|
protected function getPLZFormComponent(): TextInput
|
|
{
|
|
return TextInput::make('code')
|
|
->label('Postleitzahl')
|
|
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
|
->required();
|
|
}
|
|
|
|
protected function getLocationFormComponent(): TextInput
|
|
{
|
|
return TextInput::make('location')
|
|
->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 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 getKontoModusFormComponent(): 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 getKontoFormComponent(): Select
|
|
{
|
|
return Select::make('konto_id')
|
|
->columnSpan(4)
|
|
->label('Konto auswählen')
|
|
->belowLabel([
|
|
'Um das erstellte Profil zu aktivieren muß der Kontoinhaber die Anmeldung im Programm freischalten',
|
|
])
|
|
->visible(fn (Get $get): bool => $get('konto') == 'old')
|
|
->options(Konto::query()->pluck('company', 'id'))
|
|
->searchable()
|
|
->required();
|
|
}
|
|
}
|