generated from boboko/starter
contact page, legal pages and category page
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Lunar\Models\Collection;
|
||||
use Lunar\Models\Product;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
public function show(string $locale, Collection $collection)
|
||||
{
|
||||
$products = $collection
|
||||
->products()
|
||||
->with(['variants.prices.currency', 'media'])
|
||||
->paginate(12)
|
||||
->withQueryString()
|
||||
->through(fn (Product $product) => [
|
||||
'name' => $product->translateAttribute('name'),
|
||||
'price' => $product->variants->first()?->prices->first()?->price->decimal,
|
||||
'image' => $product->media->first()?->getUrl(),
|
||||
'href' => route('product.show', ['product' => $product]),
|
||||
]);
|
||||
|
||||
return view('category.show', [
|
||||
'collection' => $collection,
|
||||
'products' => $products,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user