From 09bcc5e13eeacd4f2428b4685c22372ff2557097 Mon Sep 17 00:00:00 2001 From: salam Date: Sun, 21 Sep 2025 18:10:18 +0200 Subject: [PATCH] registrierung wip --- app/Filament/Pages/Auth/Register.php | 267 ++++++++++-------- .../Middleware/AppUserVerifiedMiddleware.php | 6 +- app/Livewire/KontoSwitch.php | 2 +- app/Models/Konto.php | 24 +- app/Models/User.php | 73 +++-- ...0001_01_01_000000__create_kontos_table.php | 25 +- .../0001_01_01_000000_create_users_table.php | 2 - database/seeders/KontoSeeder.php | 2 +- resources/views/pages/agb.blade.php | 28 +- 9 files changed, 248 insertions(+), 181 deletions(-) diff --git a/app/Filament/Pages/Auth/Register.php b/app/Filament/Pages/Auth/Register.php index 77d73e6..44a1044 100644 --- a/app/Filament/Pages/Auth/Register.php +++ b/app/Filament/Pages/Auth/Register.php @@ -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(); + } } diff --git a/app/Http/Middleware/AppUserVerifiedMiddleware.php b/app/Http/Middleware/AppUserVerifiedMiddleware.php index e5e452b..5ec7fd6 100644 --- a/app/Http/Middleware/AppUserVerifiedMiddleware.php +++ b/app/Http/Middleware/AppUserVerifiedMiddleware.php @@ -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); } diff --git a/app/Livewire/KontoSwitch.php b/app/Livewire/KontoSwitch.php index bb4883e..50e9cee 100644 --- a/app/Livewire/KontoSwitch.php +++ b/app/Livewire/KontoSwitch.php @@ -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() diff --git a/app/Models/Konto.php b/app/Models/Konto.php index 0589124..edab50e 100644 --- a/app/Models/Konto.php +++ b/app/Models/Konto.php @@ -13,18 +13,18 @@ class Konto extends Model * @var list */ 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 // { diff --git a/app/Models/User.php b/app/Models/User.php index cf65264..03648bc 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -26,28 +26,26 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication * @var list */ 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'); }); } diff --git a/database/migrations/0001_01_01_000000__create_kontos_table.php b/database/migrations/0001_01_01_000000__create_kontos_table.php index 2e0efa7..35932b4 100644 --- a/database/migrations/0001_01_01_000000__create_kontos_table.php +++ b/database/migrations/0001_01_01_000000__create_kontos_table.php @@ -13,18 +13,19 @@ return new class extends Migration { Schema::create('kontos', function (Blueprint $table) { $table->id(); - $table->string('title')->nullable(); - $table->string('gender')->nullable(); - $table->string('first_name'); - $table->string('last_name'); - $table->string('company'); - $table->string('kontoemail')->nullable(); - $table->string('address')->nullable(); - $table->string('location')->nullable(); - $table->string('code')->nullable(); - $table->string('country')->nullable(); - $table->string('phone')->nullable(); - $table->string('uid_number')->nullable(); + $table->string('konto_title')->nullable(); + $table->string('konto_gender')->nullable(); + $table->string('konto_first_name'); + $table->string('konto_last_name'); + $table->string('konto_company'); + $table->string('konto_email')->nullable(); + $table->string('konto_address')->nullable(); + $table->string('konto_location')->nullable(); + $table->string('konto_plz')->nullable(); + $table->string('konto_country')->nullable(); + $table->string('konto_phone')->nullable(); + $table->string('konto_uid_number')->nullable(); + $table->boolean('konto_agb_akzeptiert')->default(false); $table->timestamps(); }); } diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index d694cac..13da842 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -19,8 +19,6 @@ return new class extends Migration $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); - $table->string('role'); - $table->boolean('super_admin')->default(0); $table->text('app_authentication_secret')->nullable(); $table->text('app_authentication_recovery_codes')->nullable(); diff --git a/database/seeders/KontoSeeder.php b/database/seeders/KontoSeeder.php index 475790c..437a4c8 100644 --- a/database/seeders/KontoSeeder.php +++ b/database/seeders/KontoSeeder.php @@ -12,7 +12,7 @@ class KontoSeeder extends Seeder */ public function run(): void { - $sql = "INSERT INTO `kontos` (`id`, `title`, `gender`, `first_name`, `last_name`, `company`, `address`, `location`, `code`, `phone`, `uid_number`) + $sql = "INSERT INTO `kontos` (`id`, `konto_title`, `konto_gender`, `konto_first_name`, `konto_last_name`, `konto_company`, `konto_address`, `konto_location`, `konto_plz`, `konto_phone`, `konto_uid_number`) VALUES ('1', 'Architekt', 'Herr','Bruno','Kunz','Architekt Kunz','Pradlerstraße 11','Innbsruck', '6020', '0512 457328', 'ATU 234578'), ('2', 'Architekt', 'Herr','Sepp','Unterlugauer','Architekt Unterlugauer','Seestraße 1','Innbsruck', '6020', '0512 457328', 'ATU 234578'); diff --git a/resources/views/pages/agb.blade.php b/resources/views/pages/agb.blade.php index ce67e6e..34af01b 100644 --- a/resources/views/pages/agb.blade.php +++ b/resources/views/pages/agb.blade.php @@ -2,7 +2,7 @@ Allgemeine Geschäftsbedingungen (AGB) - + 1. Geltungsbereich @@ -11,7 +11,7 @@ oder „uns“). Mit der Nutzung der Software erklärt sich der Nutzer (nachfolgend „Kunde“ oder „Sie“) mit diesen AGB einverstanden. - + 2. Vertragsgegenstand @@ -19,7 +19,7 @@ für Bauprojekte durchführen kann. Die Software wird als Software-as-a-Service (SaaS) angeboten, die über das Internet zugänglich ist. - + 3. Nutzungsrechte @@ -36,7 +36,7 @@ - + 5. Leistungen des Anbieters @@ -53,7 +53,7 @@ - + 4. Registrierung und Zugangsdaten @@ -72,7 +72,7 @@ - + 6. Verfügbarkeit und Wartung @@ -91,7 +91,7 @@ - + 7. Gebühren und Zahlungsbedingungen @@ -107,7 +107,7 @@ - + 7. Gebühren und Zahlungsbedingungen @@ -128,7 +128,7 @@ - + 8. Rechte an den Daten @@ -148,7 +148,7 @@ - + 9. Haftung und Gewährleistung @@ -172,7 +172,7 @@ - + 10. Datenschutz @@ -191,7 +191,7 @@ - + 11. Laufzeit und Kündigung @@ -206,7 +206,7 @@
  • Das Recht zur außerordentlichen Kündigung aus wichtigem Grund bleibt unberührt.
  • - + 12. Änderungen der AGB @@ -223,7 +223,7 @@ - + 13. Schlussbestimmungen