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, Product | ProductDto $_): bool { if ($user instanceof Customer) { return false; } return $user->role->isAtLeastEqualsTo(UserRole::Admin); } public function delete(Customer | User $user, Product | ProductDto $_): bool { if ($user instanceof Customer) { return false; } return $user->role->isAtLeastEqualsTo(UserRole::Admin); } public function createInco(Customer | User $user, Product | ProductDto $product): bool { if ($user instanceof Customer) { return false; } $hasInco = $product instanceof ProductDto ? $product->inco !== null : $product->inco()->exists(); return $user->role->isAtLeastEqualsTo(UserRole::Admin) && ! $hasInco; } public function updateInco(Customer | User $user, Product | ProductDto $product): bool { if ($user instanceof Customer) { return false; } $hasInco = $product instanceof ProductDto ? $product->inco !== null : $product->inco()->exists(); return $user->role->isAtLeastEqualsTo(UserRole::Admin) && $hasInco; } public function associateInco(Customer | User $user, Product | ProductDto $_): bool { if ($user instanceof Customer) { return false; } return $user->role->isAtLeastEqualsTo(UserRole::Admin); } public function syncInco(Customer | User $user, Product | ProductDto $product): bool { return $this->updateInco($user, $product); } public function toggleStatus(Customer | User $user): bool { if ($user instanceof Customer) { return false; } return $user->role->isAtLeastEqualsTo(UserRole::Admin); } public function toggleStar(Customer | User $user): bool { if ($user instanceof Customer) { return false; } return $user->role->isAtLeastEqualsTo(UserRole::Admin); } public function viewStarred(Customer | User $user): bool { if ($user instanceof Customer) { return false; } return $user->role->isAtLeastEqualsTo(UserRole::Admin); } public function viewPublished(null | Customer | User $_, Product | ProductDto $product): bool { if ($product instanceof ProductDto) { return $product->status; } $domainProduct = $this->productRepository->find($product->getId()); return $domainProduct && $domainProduct->isPublished(); } }