diff --git a/app-modules/prospect/database/migrations/2024_10_08_174318_seed_permissions_for_prospect_conversion.php b/app-modules/prospect/database/migrations/2024_10_08_174318_seed_permissions_for_prospect_conversion.php new file mode 100644 index 000000000..c1559caa7 --- /dev/null +++ b/app-modules/prospect/database/migrations/2024_10_08_174318_seed_permissions_for_prospect_conversion.php @@ -0,0 +1,38 @@ + 'Prospect Conversion', + ]; + + private array $guards = [ + 'web', + 'api', + ]; + + public function up(): void + { + collect($this->guards) + ->each(function (string $guard) { + $permissions = Arr::except($this->permissions, keys: DB::table('permissions') + ->where('guard_name', $guard) + ->pluck('name') + ->all()); + + $this->createPermissions($permissions, $guard); + }); + } + + public function down(): void + { + collect($this->guards) + ->each(fn (string $guard) => $this->deletePermissions(array_keys($this->permissions), $guard)); + } +}; diff --git a/app-modules/prospect/src/Filament/Pages/ManageProspectConversionSettings.php b/app-modules/prospect/src/Filament/Pages/ManageProspectConversionSettings.php index 1195b8efb..9f5f37c30 100644 --- a/app-modules/prospect/src/Filament/Pages/ManageProspectConversionSettings.php +++ b/app-modules/prospect/src/Filament/Pages/ManageProspectConversionSettings.php @@ -37,7 +37,10 @@ class ManageProspectConversionSettings extends SettingsPage public static function canAccess(): bool { - return ProspectConversion::active(); + /** @var User $user */ + $user = auth()->user(); + + return ProspectConversion::active() && $user->can('prospect_conversion.manage'); } public function form(Form $form): Form