68 lines
1.5 KiB
PHP
68 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Policies\Backend;
|
|
|
|
use App\Dto\ShopDto;
|
|
use App\Models\Customer;
|
|
use App\Models\Shop;
|
|
use App\Models\User;
|
|
use Domain\Enums\UserRole;
|
|
|
|
class ShopPolicy
|
|
{
|
|
public function viewAny(User | Customer $user): bool
|
|
{
|
|
if ($user instanceof Customer) {
|
|
return false;
|
|
}
|
|
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
|
}
|
|
|
|
public function view(User | Customer $user, Shop | ShopDto $_): bool
|
|
{
|
|
if ($user instanceof Customer) {
|
|
return false;
|
|
}
|
|
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
|
}
|
|
|
|
public function create(User | Customer $user): bool
|
|
{
|
|
if ($user instanceof Customer) {
|
|
return false;
|
|
}
|
|
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
|
}
|
|
|
|
public function update(User | Customer $user, Shop | ShopDto $_): bool
|
|
{
|
|
if ($user instanceof Customer) {
|
|
return false;
|
|
}
|
|
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
|
}
|
|
|
|
public function delete(User | Customer $user, Shop | ShopDto $_): bool
|
|
{
|
|
if ($user instanceof Customer) {
|
|
return false;
|
|
}
|
|
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
|
}
|
|
|
|
public function pickupExceptionUpdate(User | Customer $user, Shop | ShopDto $_): bool
|
|
{
|
|
if ($user instanceof Customer) {
|
|
return false;
|
|
}
|
|
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
|
}
|
|
}
|