Feat: Updating routes and controllers to use the updated Services coming from boboko/core

This commit is contained in:
2026-08-29 00:17:34 +03:00
parent defe1dab12
commit c7cd1138fe
9 changed files with 48 additions and 22 deletions
+9 -4
View File
@@ -2,18 +2,23 @@
namespace App\Http\Controllers;
use Lunar\Models\Collection;
use Illuminate\Http\Response;
use Modules\Core\Catalog\DTOs\ProductFilters;
use Modules\Core\Catalog\Services\CollectionService;
use Modules\Core\Catalog\Services\ProductService;
class CategoryController extends Controller
{
public function __construct(
private readonly ProductService $products,
private readonly CollectionService $collections,
) {}
public function show(string $locale, Collection $collection)
public function show(string $locale, int $collection)
{
$collectionData = $this->collections->getById($collection);
abort_if($collectionData === null, Response::HTTP_NOT_FOUND);
$perPage = 12;
$page = (int) request('page', 1);
@@ -22,7 +27,7 @@ public function show(string $locale, Collection $collection)
// real LengthAwarePaginator of plain arrays (already localized/flattened),
// not Product models.
$products = $this->products->list(
filters: new ProductFilters(collectionId: $collection->id),
filters: new ProductFilters(collectionId: $collectionData['id']),
perPage: $perPage,
page: $page,
)->through(fn (array $product) => [
@@ -33,7 +38,7 @@ public function show(string $locale, Collection $collection)
]);
return view('category.show', [
'collection' => $collection,
'collection' => $collectionData,
'products' => $products,
]);
}