33 lines
709 B
PHP
33 lines
709 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Policies\Backend;
|
||
|
|
|
||
|
|
use App\Dto\SettingDto;
|
||
|
|
use App\Models\Customer;
|
||
|
|
use App\Models\Setting;
|
||
|
|
use App\Models\User;
|
||
|
|
use Domain\Enums\UserRole;
|
||
|
|
|
||
|
|
class SettingPolicy
|
||
|
|
{
|
||
|
|
public function view(User | Customer $user, Setting | SettingDto | null $_ = null): bool
|
||
|
|
{
|
||
|
|
if ($user instanceof Customer) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function update(User | Customer $user, Setting | SettingDto | null $_ = null): bool
|
||
|
|
{
|
||
|
|
if ($user instanceof Customer) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
||
|
|
}
|
||
|
|
}
|