Skip to content

Commit

Permalink
added permission for prospect conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
payal-canyon committed Oct 18, 2024
1 parent 5eaa3bf commit 7505857
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Migrations\Migration;
use Database\Migrations\Concerns\CanModifyPermissions;

return new class () extends Migration {
use CanModifyPermissions;

private array $permissions = [
'prospect_conversion.manage' => '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));
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7505857

Please sign in to comment.