Files
ladill-servers/app/Policies/HostingAccountPolicy.php
isaaccladandCursor b6c8ac343f Extract Ladill Servers as standalone app at servers.ladill.com.
VPS and dedicated server ordering, managed panels, SSO, billing, and launcher integration — forked from hosting infrastructure with server-focused routes and dashboard.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 19:18:30 +00:00

115 lines
3.0 KiB
PHP

<?php
namespace App\Policies;
use App\Models\HostingAccount;
use App\Models\User;
class HostingAccountPolicy
{
public function viewAccount(User $user, HostingAccount $account): bool
{
return $this->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();
}
}