diff --git a/app/Filament/Resources/Users/UserResource.php b/app/Filament/Resources/Users/UserResource.php index 390bad4..bccec43 100644 --- a/app/Filament/Resources/Users/UserResource.php +++ b/app/Filament/Resources/Users/UserResource.php @@ -68,11 +68,19 @@ class UserResource extends Resource public static function getEloquentQuery(): Builder { - return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id); + if (auth()->user()->super_admin) { + return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id); + } else { + return parent::getEloquentQuery()->where('super_admin', false)->where('konto_id', auth()->user()->konto_id); + } } public static function getNavigationBadge(): ?string { - return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id)->count(); + if (auth()->user()->super_admin) { + return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id)->count(); + } else { + return parent::getEloquentQuery()->where('super_admin', false)->where('konto_id', auth()->user()->konto_id)->count(); + } } } diff --git a/app/Models/User.php b/app/Models/User.php index 47e567c..d849e34 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -75,46 +75,6 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication protected static function booted(): void { static::addGlobalScope(new KontoScope); - - // static::creating(function (User $user) { - - // if (isset($user->konto_title)) { - - // $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'); - // }); } public function konto(): HasOne 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 07bfeea..e30694c 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -20,6 +20,7 @@ return new class extends Migration $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->boolean('agb_akzeptiert')->default(false); + $table->boolean('super_admin')->default(false); $table->text('app_authentication_secret')->nullable(); $table->text('app_authentication_recovery_codes')->nullable(); diff --git a/database/seeders/RolesAndPermissionsSeeder.php b/database/seeders/RolesAndPermissionsSeeder.php index 729ea73..6d85976 100644 --- a/database/seeders/RolesAndPermissionsSeeder.php +++ b/database/seeders/RolesAndPermissionsSeeder.php @@ -27,6 +27,7 @@ class RolesAndPermissionsSeeder extends Seeder 'email' => 'ht@webwerkstatt.tirol', 'password' => Hash::make('salam'), 'agb_akzeptiert' => true, + 'super_admin' => true, 'app_verified_at' => now(), 'email_verified_at' => now(), ]); diff --git a/resources/views/components/login-links.blade.php b/resources/views/components/login-links.blade.php index f9078c4..0bb5b68 100644 --- a/resources/views/components/login-links.blade.php +++ b/resources/views/components/login-links.blade.php @@ -1,6 +1,6 @@
@env('local') - - + + @endenv