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