@@ 8-25 (lines=18) @@ | ||
5 | use Illuminate\Console\Command; |
|
6 | use Spatie\Permission\Models\Permission; |
|
7 | ||
8 | class CreatePermission extends Command |
|
9 | { |
|
10 | protected $signature = 'permission:create-permission |
|
11 | {name : The name of the permission} |
|
12 | {guard? : Optional guard, default web}'; |
|
13 | ||
14 | protected $description = 'Create a permission'; |
|
15 | ||
16 | public function handle() |
|
17 | { |
|
18 | $permission = Permission::create([ |
|
19 | 'name' => $this->argument('name'), |
|
20 | 'guard_name' => $this->argument('guard'), |
|
21 | ]); |
|
22 | ||
23 | $this->info("Permission `{$permission->name}` created"); |
|
24 | } |
|
25 | } |
|
26 |
@@ 8-25 (lines=18) @@ | ||
5 | use Illuminate\Console\Command; |
|
6 | use Spatie\Permission\Models\Role; |
|
7 | ||
8 | class CreateRole extends Command |
|
9 | { |
|
10 | protected $signature = 'permission:create-role |
|
11 | {name : The name of the role} |
|
12 | {guard? : Optional guard, default web}'; |
|
13 | ||
14 | protected $description = 'Create a role'; |
|
15 | ||
16 | public function handle() |
|
17 | { |
|
18 | $permission = Role::create([ |
|
19 | 'name' => $this->argument('name'), |
|
20 | 'guard_name' => $this->argument('guard'), |
|
21 | ]); |
|
22 | ||
23 | $this->info("Role `{$permission->name}` created"); |
|
24 | } |
|
25 | } |
|
26 |