registrierung wip

This commit is contained in:
salam committed 2025-09-21 18:10:18 +02:00
1 parent 24871d41a9
commit 09bcc5e13e
9 files changed
+248 -181

No files matched your search

+152 -115
View File
@@ -7,7 +7,6 @@ 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;
@@ -28,11 +27,12 @@ class Register extends BaseRegister
->icon('lucide-user-plus')
->description('Benutzer anlegen.')
->schema([
$this->getGenderFormComponent(),
$this->getNameFormComponent(),
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getPasswordConfirmationFormComponent(),
]),
])->columnSpan(3),
Wizard\Step::make('Konto')
// ->columns(4)
->icon('lucide-key-square')
@@ -47,20 +47,25 @@ class Register extends BaseRegister
->schema([
$this->getCompanyFormComponent(),
$this->getUIDFormComponent(),
$this->getLocationFormComponent(),
$this->getPLZFormComponent(),
$this->getCountryFormComponent(),
$this->getLocationFormComponent(),
$this->getAdresseFormComponent(),
$this->getGenderFormComponent(),
$this->getFirstNameFormComponent(),
$this->getLastNameFormComponent(),
$this->getCountryFormComponent(),
])->columnSpan(4),
Fieldset::make('Kontaktperson')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->schema([
$this->getKontoGenderFormComponent(),
$this->getTitleFormComponent(),
$this->getKontoFirstNameFormComponent(),
$this->getKontoLastNameFormComponent(),
$this->getKontoEmailFormComponent(),
$this->getPhoneFormComponent(),
])->columnSpan(4),
]),
Wizard\Step::make('AGB')
->icon('lucide-key-square')
->icon('lucide-receipt-text')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->description(' Allgemein Geschäftsbedignugen')
->schema([
@@ -68,7 +73,7 @@ class Register extends BaseRegister
->visible(fn (Get $get): bool => $get('konto') == 'new')
->schema([
$this->getABGFormComponent(),
])->columnSpan(4),
]),
View::make('pages.agb'),
]),
@@ -77,111 +82,9 @@ class Register extends BaseRegister
]);
}
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();
}
/**
* MODUS
*/
protected function getKontoModusFormComponent(): Select
{
return Select::make('konto')
@@ -200,6 +103,24 @@ class Register extends BaseRegister
->required();
}
/**
* USER
*/
protected function getGenderFormComponent(): Select
{
return Select::make('gender')
->label('Geschlecht')
->options([
'Herr' => 'Herr',
'Frau' => 'Frau',
'Non-binary' => 'Non-binary',
])
->required();
}
/**
* KONTO WÄHLEN
*/
protected function getKontoFormComponent(): Select
{
return Select::make('konto_id')
@@ -209,8 +130,124 @@ class Register extends BaseRegister
'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'))
->options(Konto::query()->pluck('konto_company', 'id'))
->searchable()
->required();
}
/**
* KONTO NEU
*/
protected function getABGFormComponent(): Checkbox
{
return Checkbox::make('konto_agb_akzeptiert')
->label('ABG akzeptieren')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->required();
}
protected function getTitleFormComponent(): TextInput
{
return TextInput::make('konto_title')
->label('Title')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->required();
}
protected function getKontoGenderFormComponent(): Select
{
return Select::make('konto_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 getKontoFirstNameFormComponent(): TextInput
{
return TextInput::make('konto_first_name')
->label('Vorname')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->required();
}
protected function getKontoLastNameFormComponent(): TextInput
{
return TextInput::make('konto_last_name')
->label('Nachname')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->required();
}
protected function getCompanyFormComponent(): TextInput
{
return TextInput::make('konto_company')
->label('Firma')
->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')
->unique(table: Konto::class)
->required();
}
protected function getAdresseFormComponent(): TextInput
{
return TextInput::make('konto_address')
->label('Adresse')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->required();
}
protected function getLocationFormComponent(): TextInput
{
return TextInput::make('konto_location')
->label('Ort')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->required();
}
protected function getPLZFormComponent(): TextInput
{
return TextInput::make('konto_plz')
->label('Postleitzahl')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->required();
}
protected function getPhoneFormComponent(): PhoneInput
{
return PhoneInput::make('konto_phone')
->label('Telefon')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->defaultCountry('AT');
}
protected function getCountryFormComponent(): TextInput
{
return TextInput::make('konto_country')
->label('Land')
->default('Österreich')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->required();
}
protected function getUIDFormComponent(): TextInput
{
return TextInput::make('konto_uid_number')
->label('UID Nummer')
->visible(fn (Get $get): bool => $get('konto') == 'new')
->rules([new VatNumber])
->required();
}
}
@@ -15,9 +15,9 @@ class AppUserVerifiedMiddleware
*/
public function handle(Request $request, Closure $next): Response
{
if (is_null($request->user()->app_verified_at)) {
abort(Response::HTTP_FORBIDDEN, 'Ihr Konto muss von einem Administrator verifiziert werden.');
}
// if (is_null($request->user()->app_verified_at)) {
// abort(Response::HTTP_FORBIDDEN, 'Ihr Konto muss von einem Administrator verifiziert werden.');
// }
return $next($request);
}
+1 -1
View File
@@ -12,7 +12,7 @@ class KontoSwitch extends Component
public function mount()
{
$this->kontos = Konto::pluck('company', 'id')->all();
$this->kontos = Konto::pluck('konto_company', 'id')->all();
}
public function render()
+12 -12
View File
@@ -13,18 +13,18 @@ class Konto extends Model
* @var list<string>
*/
protected $fillable = [
'title',
'gender',
'first_name',
'last_name',
'company',
'address',
'location',
'code',
'country',
'kontoemail',
'phone',
'uid_number',
'konto_title',
'konto_gender',
'konto_first_name',
'konto_last_name',
'konto_company',
'konto_email',
'konto_address',
'konto_location',
'konto_plz',
'konto_country',
'konto_phone',
'konto_uid_number',
];
// protected static function booted(): void
// {
+52 -21
View File
@@ -26,28 +26,26 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
* @var list<string>
*/
protected $fillable = [
'name',
'first_name',
'last_name',
'email',
'konto_id',
'password',
'role',
'super_admin',
'app_verified_at',
'first_name',
'last_name',
'gender',
'name',
'email',
'password',
'app_verified_at',
'title',
'company',
'address',
'location',
'code',
'country',
'kontoemail',
'phone',
'uid_number',
'konto_title',
'konto_gender',
'konto_first_name',
'konto_last_name',
'konto_company',
'konto_email',
'konto_address',
'konto_location',
'konto_plz',
'konto_country',
'konto_phone',
'konto_uid_number',
'konto_agb_akzeptiert',
];
/**
@@ -85,9 +83,42 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
static::creating(function (User $user) {
// dd($user);
if (isset($user->konto_title)) {
$user->role = 'gutachter';
$konto = Konto::create([
'konto_title' => $user->konto_title,
'konto_gender' => $user->konto_gender,
'konto_company' => $user->konto_company,
'konto_uid_number' => $user->konto_uid_number,
'konto_location' => $user->konto_location,
'konto_plz' => $user->konto_plz,
'konto_agb_akzeptiert' => $user->konto_agb_akzeptiert,
'konto_country' => $user->konto_country,
'konto_address' => $user->konto_address,
'konto_first_name' => $user->konto_first_name,
'konto_last_name' => $user->konto_last_name,
'konto_email' => $user->konto_email,
'konto_phone' => $user->konto_phone,
]);
$user->konto_id = $konto->id;
unset($user->konto_title);
unset($user->konto_gender);
unset($user->konto_company);
unset($user->konto_uid_number);
unset($user->konto_location);
unset($user->konto_plz);
unset($user->konto_agb_akzeptiert);
unset($user->konto_country);
unset($user->konto_address);
unset($user->konto_first_name);
unset($user->konto_last_name);
unset($user->konto_email);
unset($user->konto_phone);
}
$user->app_verified_at = now();
$user->email_verified_at = now();
$user->assignRole('gutachter');
});
}