diff --git a/api/app/Models/Workspace.php b/api/app/Models/Workspace.php index acdc1463..b200f7ff 100644 --- a/api/app/Models/Workspace.php +++ b/api/app/Models/Workspace.php @@ -204,11 +204,11 @@ public function forms() return $this->hasMany(Form::class); } - public function isReadonlyUser(User $user) + public function isReadonlyUser(?User $user) { - return $this->users() + return $user ? $this->users() ->wherePivot('user_id', $user->id) ->wherePivot('role', User::ROLE_READONLY) - ->exists(); + ->exists() : false; } }