generated from boboko/starter
33 lines
961 B
PHP
33 lines
961 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Catalog\ProductListing;
|
|
use App\Catalog\ProductListingPage;
|
|
use Illuminate\Http\Response;
|
|
use Modules\Core\Catalog\Services\CollectionService;
|
|
|
|
class CategoryController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly ProductListingPage $listingPage,
|
|
private readonly CollectionService $collections,
|
|
) {}
|
|
|
|
public function show(string $locale, int $collection)
|
|
{
|
|
$collectionData = $this->collections->getById($collection);
|
|
abort_if($collectionData === null, Response::HTTP_NOT_FOUND);
|
|
|
|
$listing = ProductListing::fromRequest(request());
|
|
|
|
$data = $this->listingPage->build(
|
|
$listing,
|
|
fn (array $query) => route('category.show', ['id' => $collectionData['id']] + $query),
|
|
$collectionData['id'],
|
|
);
|
|
|
|
return view('category.show', [...$data, 'collection' => $collectionData]);
|
|
}
|
|
}
|