From 38b90e1a371a1a92901f900b935ca0fb75e1ce50 Mon Sep 17 00:00:00 2001 From: Christoph Kempen Date: Tue, 30 Jan 2024 15:46:13 +0100 Subject: [PATCH] remove hardcoded Permission model (#150) I use my own Permission model instead of the default one. But your permission generator uses the hardcoded spatie version instead of the one specified in the permission config. This small fix is to just use the correct Model :-D --- src/Commands/Permission.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Commands/Permission.php b/src/Commands/Permission.php index 50c998e..1dd09c0 100644 --- a/src/Commands/Permission.php +++ b/src/Commands/Permission.php @@ -10,7 +10,6 @@ use Illuminate\Support\Str; use ReflectionClass; use ReflectionException; -use Spatie\Permission\Models\Permission as PermissionModel; class Permission extends Command { @@ -20,8 +19,8 @@ class Permission extends Command private array $policies = []; - protected $signature = 'permissions:sync - {--C|clean} + protected $signature = 'permissions:sync + {--C|clean} {--P|policies} {--O|oep} {--Y|yes-to-all}'; @@ -32,6 +31,7 @@ public function __construct() { parent::__construct(); $this->config = config('filament-spatie-roles-permissions.generator'); + } /** @@ -50,9 +50,11 @@ public function handle(): void $this->prepareCustomPermissions(); + $permissionModel = config('permission.models.permission'); + foreach ($this->permissions as $permission) { $this->comment('Syncing Permission for: '.$permission['name']); - PermissionModel::firstOrCreate($permission); + $permissionModel::firstOrCreate($permission); } }