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>
28 lines
614 B
PHP
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;
|
|
}
|
|
}
|