From fcce45ae72d17273415b405a58991b7deed7f016 Mon Sep 17 00:00:00 2001 From: Chirag Chhatrala Date: Thu, 19 Dec 2024 15:40:40 +0530 Subject: [PATCH] Fix isReadonlyUser --- api/app/Models/Workspace.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; } }