@@ 30-43 (lines=14) @@ | ||
27 | $this->setTable(config('permission.table_names.permissions')); |
|
28 | } |
|
29 | ||
30 | public static function create(array $attributes = []) |
|
31 | { |
|
32 | $attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard'); |
|
33 | ||
34 | if (static::getPermissions()->where('name', $attributes['name'])->where('guard_name', $attributes['guard_name'])->first()) { |
|
35 | throw PermissionAlreadyExists::create($attributes['name'], $attributes['guard_name']); |
|
36 | } |
|
37 | ||
38 | if (isNotLumen() && app()::VERSION < '5.4') { |
|
39 | return parent::create($attributes); |
|
40 | } |
|
41 | ||
42 | return static::query()->create($attributes); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * A permission can be applied to roles. |
@@ 31-44 (lines=14) @@ | ||
28 | $this->setTable(config('permission.table_names.roles')); |
|
29 | } |
|
30 | ||
31 | public static function create(array $attributes = []) |
|
32 | { |
|
33 | $attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard'); |
|
34 | ||
35 | if (static::where('name', $attributes['name'])->where('guard_name', $attributes['guard_name'])->first()) { |
|
36 | throw RoleAlreadyExists::create($attributes['name'], $attributes['guard_name']); |
|
37 | } |
|
38 | ||
39 | if (isNotLumen() && app()::VERSION < '5.4') { |
|
40 | return parent::create($attributes); |
|
41 | } |
|
42 | ||
43 | return static::query()->create($attributes); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * A role may be given various permissions. |