diff --git a/src/Exceptions/GuardDoesNotMatch.php b/src/Exceptions/GuardDoesNotMatch.php index d17b96d..9086988 100644 --- a/src/Exceptions/GuardDoesNotMatch.php +++ b/src/Exceptions/GuardDoesNotMatch.php @@ -9,13 +9,14 @@ class GuardDoesNotMatch extends InvalidArgumentException { public static function create(string $givenGuard, Collection $expectedGuards) { - $message = new static("The given role or permission should use guard `{$expectedGuards->implode(', ')}` instead of `{$givenGuard}`."); + $expect = $expectedGuards->implode(', '); + $message = new static("The given role or permission should use guard `{$expect}` instead of `{$givenGuard}`."); if (config('permission.log_registration_exception')) { $logger = app('log'); $logger->alert($message); } - + return $message; } } diff --git a/src/Models/Permission.php b/src/Models/Permission.php index ab0d0e8..36077fe 100644 --- a/src/Models/Permission.php +++ b/src/Models/Permission.php @@ -31,8 +31,10 @@ public static function create(array $attributes = []) { $attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard'); - if (static::getPermissions()->where('name', $attributes['name'])->where('guard_name', - $attributes['guard_name'])->first()) { + if (static::getPermissions()->where('name', $attributes['name'])->where( + 'guard_name', + $attributes['guard_name'] + )->first()) { throw PermissionAlreadyExists::create($attributes['name'], $attributes['guard_name']); }