Files
fotospiel-app/app/Policies/TenantPolicy.php
Codex Agent 3de1d3deab
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled
Misc unrelated updates
2026-01-12 10:31:31 +01:00

65 lines
1.3 KiB
PHP

<?php
namespace App\Policies;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class TenantPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->isSuperAdmin();
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Tenant $tenant): bool
{
if ($user->role === 'tenant_admin') {
return (int) $user->tenant_id === (int) $tenant->getKey();
}
return false;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->isSuperAdmin();
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Tenant $tenant): bool
{
return $user->isSuperAdmin();
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Tenant $tenant): bool
{
return $user->isSuperAdmin();
}
/**
* Custom ability for suspending a tenant.
*/
public function suspend(User $user, Tenant $tenant): bool
{
return $user->isSuperAdmin();
}
}