ldc-boutique-cnc-sable/app/Policies/Backend/DiscountPolicy.php

59 lines
1.3 KiB
PHP

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