isOwner($user, $account); } public function viewPanel(User $user, HostingAccount $account): bool { return $this->isOwner($user, $account) || $this->isDeveloper($user, $account); } public function manageFiles(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function deleteFiles(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function viewDomains(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function manageDomains(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function manageDatabases(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function managePhp(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function useTerminal(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function manageSsl(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function manageCron(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function viewLogs(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function clearLogs(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function manageApps(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function viewSettings(User $user, HostingAccount $account): bool { return $this->viewPanel($user, $account); } public function manageSettings(User $user, HostingAccount $account): bool { return $this->isOwner($user, $account); } public function changePassword(User $user, HostingAccount $account): bool { return $this->isOwner($user, $account); } private function isOwner(User $user, HostingAccount $account): bool { return (int) $account->user_id === (int) $user->id; } private function isDeveloper(User $user, HostingAccount $account): bool { if ($this->isOwner($user, $account)) { return false; } if ($account->relationLoaded('teamMembers')) { return $account->teamMembers->contains('user_id', $user->id); } return $account->teamMembers() ->where('user_id', $user->id) ->exists(); } }