Files
fewo-stommer/app/Policies/UserPolicy.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

28 lines
614 B
PHP

<?php
namespace App\Policies;
use App\Enums\Permission;
use App\Models\User;
/**
* Only administrators of the current landlord manage accounts. A shared account is detached, not deleted,
* and nobody can delete their own account.
*/
class UserPolicy extends RolePolicy
{
protected function permission(): Permission
{
return Permission::Users;
}
public function delete(User $user, ?User $model = null): bool
{
if (! $this->allows($user) || $user->is($model)) {
return false;
}
return $model === null || $model->tenants()->count() < 2;
}
}