Files
fewo-stommer/app/Policies/RolePolicy.php
T
LarsandCursor 8ebc1a3878 Assign the existing site to one landlord so stommer.info can run tenancy.
Seebad 0.3 stays in this release. With a single landlord every host still reaches the default website.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-23 12:00:11 +02:00

56 lines
1.1 KiB
PHP

<?php
namespace App\Policies;
use App\Enums\Permission;
use App\Models\User;
/**
* Grants every ability that the current membership includes. The operator counts as administrator
* of the landlord that is open. A new role is added on UserRole, not in each policy.
*/
abstract class RolePolicy
{
abstract protected function permission(): Permission;
public function viewAny(User $user): bool
{
return $this->allows($user);
}
public function view(User $user): bool
{
return $this->allows($user);
}
public function create(User $user): bool
{
return $this->allows($user);
}
public function update(User $user): bool
{
return $this->allows($user);
}
public function delete(User $user): bool
{
return $this->allows($user);
}
public function deleteAny(User $user): bool
{
return $this->allows($user);
}
public function reorder(User $user): bool
{
return $this->allows($user);
}
protected function allows(User $user): bool
{
return (bool) $user->currentRole()?->grants($this->permission());
}
}