1 | <?php |
||
2 | |||
3 | namespace Helldar\Roles\Traits; |
||
4 | |||
5 | use Helldar\Roles\Models\Permission; |
||
6 | use Helldar\Roles\Models\Role; |
||
7 | use Illuminate\Support\Str; |
||
8 | |||
9 | trait Commands |
||
10 | { |
||
11 | use Searchable; |
||
12 | |||
13 | protected $slug; |
||
14 | |||
15 | protected function slug(): string |
||
16 | { |
||
17 | if (is_null($this->slug)) { |
||
18 | $slug = $this->argument('slug'); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
19 | |||
20 | $this->slug = Str::slug($slug, '_'); |
||
21 | } |
||
22 | |||
23 | return $this->slug; |
||
24 | } |
||
25 | |||
26 | protected function roleIsExist(): bool |
||
27 | { |
||
28 | return $this->searchExist(Role::class, $this->slug()); |
||
29 | } |
||
30 | |||
31 | protected function roleIsDoesntExist(): bool |
||
32 | { |
||
33 | return ! $this->roleIsExist(); |
||
34 | } |
||
35 | |||
36 | protected function permissionIsExist(): bool |
||
37 | { |
||
38 | return $this->searchExist(Permission::class, $this->slug()); |
||
39 | } |
||
40 | |||
41 | protected function permissionIsDoesntExist(): bool |
||
42 | { |
||
43 | return ! $this->permissionIsExist(); |
||
44 | } |
||
45 | } |
||
46 |