-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dba7d6
commit f3e81bd
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
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,17 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use Illuminate\Support\Facades\Artisan; | ||
|
||
class PermissionsSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
Artisan::call('permissions:sync'); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use Spatie\Permission\Models\Permission; | ||
use Spatie\Permission\Models\Role; | ||
|
||
class RolesSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
$adminRole = Role::firstOrCreate(['name' => 'admin']); | ||
$permissions = Permission::where('guard_name', 'web')->pluck('id')->toArray(); | ||
$adminRole->syncPermissions($permissions); | ||
|
||
$freeRole = Role::firstOrCreate(['name' => 'free']); | ||
$freePermissions = Permission::where('guard_name', 'web')->pluck('id')->toArray(); | ||
$freeRole->syncPermissions($freePermissions); | ||
} | ||
} |