mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-09 20:11:22 +00:00
Refactor models.
This commit is contained in:
@@ -47,19 +47,19 @@ class UserGroup extends Model
|
||||
public static function routeBinder(string $value): self
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$userGroupId = (int) $value;
|
||||
$userGroupId = (int)$value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
|
||||
/** @var null|UserGroup $userGroup */
|
||||
$userGroup = self::find($userGroupId);
|
||||
$userGroup = self::find($userGroupId);
|
||||
if (null === $userGroup) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
// need at least ready only to be aware of the user group's existence,
|
||||
// but owner/full role (in the group) or global owner role may overrule this.
|
||||
$access = $user->hasRoleInGroupOrOwner($userGroup, UserRoleEnum::READ_ONLY) || $user->hasRole('owner');
|
||||
$access = $user->hasRoleInGroupOrOwner($userGroup, UserRoleEnum::READ_ONLY) || $user->hasRole('owner');
|
||||
if ($access) {
|
||||
return $userGroup;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user