refactor(catalog): extract visible items query
This commit is contained in:
@@ -24,7 +24,7 @@ class CatalogService
|
||||
{
|
||||
public function __construct(
|
||||
protected AttachmentService $attachmentService,
|
||||
private readonly CatalogItemAllowanceService $allowances,
|
||||
private readonly VisibleCatalogItemsQuery $visibleCatalogItems,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -262,8 +262,8 @@ class CatalogService
|
||||
'bundleComponents.variant.catalogItem',
|
||||
]);
|
||||
|
||||
$paginator = $this->allowances
|
||||
->applyProductVisibilityPolicy($query)
|
||||
$paginator = $this->visibleCatalogItems
|
||||
->apply($query)
|
||||
->orderByRaw(
|
||||
'CASE WHEN LOWER(nombre) = ? THEN 0 WHEN LOWER(nombre) LIKE ? THEN 1 ELSE 2 END',
|
||||
[$normalizedTerm, $startsWithPattern],
|
||||
@@ -299,8 +299,8 @@ class CatalogService
|
||||
'bundleComponents.variant.catalogItem',
|
||||
]);
|
||||
|
||||
return $this->allowances
|
||||
->applyProductVisibilityPolicy($query)
|
||||
return $this->visibleCatalogItems
|
||||
->apply($query)
|
||||
->orderBy('nombre')
|
||||
->paginate(perPage: $perPage, pageName: 'page', page: $page);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user