@@ -26,7 +26,7 @@ class Permission extends Model implements PermissionContract
26
26
27
27
public function __construct (array $ attributes = [])
28
28
{
29
- $ attributes ['guard_name ' ] = $ attributes [ ' guard_name ' ] ?? config ( ' auth.defaults.guard ' );
29
+ $ attributes ['guard_name ' ] ??= Guard:: getDefaultName ( static ::class );
30
30
31
31
parent ::__construct ($ attributes );
32
32
@@ -41,7 +41,7 @@ public function __construct(array $attributes = [])
41
41
*/
42
42
public static function create (array $ attributes = [])
43
43
{
44
- $ attributes ['guard_name ' ] = $ attributes [ ' guard_name ' ] ?? Guard::getDefaultName (static ::class);
44
+ $ attributes ['guard_name ' ] ??= Guard::getDefaultName (static ::class);
45
45
46
46
$ permission = static ::getPermission (['name ' => $ attributes ['name ' ], 'guard_name ' => $ attributes ['guard_name ' ]]);
47
47
@@ -88,7 +88,7 @@ public function users(): BelongsToMany
88
88
*/
89
89
public static function findByName (string $ name , ?string $ guardName = null ): PermissionContract
90
90
{
91
- $ guardName = $ guardName ?? Guard::getDefaultName (static ::class);
91
+ $ guardName ??= Guard::getDefaultName (static ::class);
92
92
$ permission = static ::getPermission (['name ' => $ name , 'guard_name ' => $ guardName ]);
93
93
if (! $ permission ) {
94
94
throw PermissionDoesNotExist::create ($ name , $ guardName );
@@ -106,7 +106,7 @@ public static function findByName(string $name, ?string $guardName = null): Perm
106
106
*/
107
107
public static function findById (int |string $ id , ?string $ guardName = null ): PermissionContract
108
108
{
109
- $ guardName = $ guardName ?? Guard::getDefaultName (static ::class);
109
+ $ guardName ??= Guard::getDefaultName (static ::class);
110
110
$ permission = static ::getPermission ([(new static )->getKeyName () => $ id , 'guard_name ' => $ guardName ]);
111
111
112
112
if (! $ permission ) {
@@ -123,7 +123,7 @@ public static function findById(int|string $id, ?string $guardName = null): Perm
123
123
*/
124
124
public static function findOrCreate (string $ name , ?string $ guardName = null ): PermissionContract
125
125
{
126
- $ guardName = $ guardName ?? Guard::getDefaultName (static ::class);
126
+ $ guardName ??= Guard::getDefaultName (static ::class);
127
127
$ permission = static ::getPermission (['name ' => $ name , 'guard_name ' => $ guardName ]);
128
128
129
129
if (! $ permission ) {
0 commit comments