-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added permission for prospect conversion
- Loading branch information
1 parent
5eaa3bf
commit 7505857
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ospect/database/migrations/2024_10_08_174318_seed_permissions_for_prospect_conversion.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters