32 lines
689 B
PHP
32 lines
689 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Policies\Frontend;
|
|
|
|
use App\Models\Customer;
|
|
use App\Models\User;
|
|
use Domain\Models\ValueObjects\BasketProduct;
|
|
use Domain\Services\ProductAvailabilityService;
|
|
|
|
class BasketPolicy
|
|
{
|
|
public function __construct(
|
|
private readonly ProductAvailabilityService $productService
|
|
) {
|
|
}
|
|
|
|
public function viewTotal(null | User | Customer $_): bool
|
|
{
|
|
return $_ !== null;
|
|
}
|
|
|
|
public function viewPrices(null | User | Customer $_, BasketProduct $product): bool
|
|
{
|
|
if ($_ === null) {
|
|
return false;
|
|
}
|
|
|
|
return $this->productService->isBasketProductPublished($product);
|
|
}
|
|
}
|