From d2c3860a38088b8d35b65d7bf39b04b5e163dc93 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 29 Oct 2024 11:32:04 +0100 Subject: [PATCH] make sure roles always use "web" guard name --- app/Filament/Resources/RoleResource.php | 3 +-- app/Models/Role.php | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/RoleResource.php b/app/Filament/Resources/RoleResource.php index 306c9676da..510a03a88e 100644 --- a/app/Filament/Resources/RoleResource.php +++ b/app/Filament/Resources/RoleResource.php @@ -6,7 +6,6 @@ use App\Enums\RolePermissionPrefixes; use App\Filament\Resources\RoleResource\Pages; use App\Models\Role; -use Filament\Facades\Filament; use Filament\Forms\Components\Actions\Action; use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\Component; @@ -71,7 +70,7 @@ public static function form(Form $form): Form ->disabled(fn (Get $get) => $get('name') === Role::ROOT_ADMIN), TextInput::make('guard_name') ->label('Guard Name') - ->default(Filament::getCurrentPanel()?->getAuthGuard() ?? '') + ->default(Role::DEFAULT_GUARD_NAME) ->nullable() ->hidden(), Fieldset::make('Permissions') diff --git a/app/Models/Role.php b/app/Models/Role.php index 1274b2d6c3..d93bbce128 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -19,6 +19,8 @@ class Role extends BaseRole public const ROOT_ADMIN = 'Root Admin'; + public const DEFAULT_GUARD_NAME = 'web'; + public const MODEL_SPECIFIC_PERMISSIONS = [ 'egg' => [ 'import', @@ -41,7 +43,7 @@ public function isRootAdmin(): bool public static function getRootAdmin(): self { /** @var self $role */ - $role = self::findOrCreate(self::ROOT_ADMIN); + $role = self::findOrCreate(self::ROOT_ADMIN, self::DEFAULT_GUARD_NAME); return $role; }