Skip to content

Commit 39bb908

Browse files
authored
Update Role.php
1 parent bfb824a commit 39bb908

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Models/Role.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Role extends Model implements RoleContract
2727

2828
public function __construct(array $attributes = [])
2929
{
30-
$attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard');
30+
$attributes['guard_name'] ??= Guard::getDefaultName(static::class);
3131

3232
parent::__construct($attributes);
3333

@@ -42,7 +42,7 @@ public function __construct(array $attributes = [])
4242
*/
4343
public static function create(array $attributes = [])
4444
{
45-
$attributes['guard_name'] = $attributes['guard_name'] ?? Guard::getDefaultName(static::class);
45+
$attributes['guard_name'] ??= Guard::getDefaultName(static::class);
4646

4747
$params = ['name' => $attributes['name'], 'guard_name' => $attributes['guard_name']];
4848
if (app(PermissionRegistrar::class)->teams) {
@@ -97,7 +97,7 @@ public function users(): BelongsToMany
9797
*/
9898
public static function findByName(string $name, ?string $guardName = null): RoleContract
9999
{
100-
$guardName = $guardName ?? Guard::getDefaultName(static::class);
100+
$guardName ??= Guard::getDefaultName(static::class);
101101

102102
$role = static::findByParam(['name' => $name, 'guard_name' => $guardName]);
103103

@@ -115,7 +115,7 @@ public static function findByName(string $name, ?string $guardName = null): Role
115115
*/
116116
public static function findById(int|string $id, ?string $guardName = null): RoleContract
117117
{
118-
$guardName = $guardName ?? Guard::getDefaultName(static::class);
118+
$guardName ??= Guard::getDefaultName(static::class);
119119

120120
$role = static::findByParam([(new static)->getKeyName() => $id, 'guard_name' => $guardName]);
121121

@@ -133,7 +133,7 @@ public static function findById(int|string $id, ?string $guardName = null): Role
133133
*/
134134
public static function findOrCreate(string $name, ?string $guardName = null): RoleContract
135135
{
136-
$guardName = $guardName ?? Guard::getDefaultName(static::class);
136+
$guardName ??= Guard::getDefaultName(static::class);
137137

138138
$role = static::findByParam(['name' => $name, 'guard_name' => $guardName]);
139139

0 commit comments

Comments
 (0)