2026-06-14 21:32:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Policies\Backend;
|
|
|
|
|
|
2026-09-30 11:20:39 +02:00
|
|
|
use App\Dto\ShopDto;
|
2026-06-14 21:32:07 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-30 11:20:39 +02:00
|
|
|
public function view(User | Customer $user, Shop | ShopDto $_): bool
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-30 11:20:39 +02:00
|
|
|
public function update(User | Customer $user, Shop | ShopDto $_): bool
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
|
|
|
|
if ($user instanceof Customer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-30 11:20:39 +02:00
|
|
|
public function delete(User | Customer $user, Shop | ShopDto $_): bool
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
|
|
|
|
if ($user instanceof Customer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-30 11:20:39 +02:00
|
|
|
public function pickupExceptionUpdate(User | Customer $user, Shop | ShopDto $_): bool
|
2026-06-14 21:32:07 +02:00
|
|
|
{
|
|
|
|
|
if ($user instanceof Customer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $user->role->isAtLeastEqualsTo(UserRole::Admin);
|
|
|
|
|
}
|
|
|
|
|
}
|