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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
public function index(string $locale)
|
||||
{
|
||||
return view('contact');
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,19 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\StoicPage;
|
||||
use Lunar\Models\Product;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
public function index(string $locale)
|
||||
{
|
||||
$page = StoicPage::firstWhere('slug', 'home');
|
||||
|
||||
if (! $page) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$products = Product::with(['variants.prices.currency', 'media'])
|
||||
->inRandomOrder()
|
||||
->limit(13)
|
||||
@@ -20,6 +27,7 @@ public function index()
|
||||
]);
|
||||
|
||||
return view('home', [
|
||||
'page' => $page,
|
||||
'heroProducts' => $products->take(5)->values(),
|
||||
'classicsProducts' => $products->slice(5)->values(),
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\StoicPage;
|
||||
|
||||
class LegalPageController extends Controller
|
||||
{
|
||||
public function terms(string $locale)
|
||||
{
|
||||
return $this->show('terms-and-conditions');
|
||||
}
|
||||
|
||||
public function shippingReturns(string $locale)
|
||||
{
|
||||
return $this->show('shipping-returns');
|
||||
}
|
||||
|
||||
public function privacy(string $locale)
|
||||
{
|
||||
return $this->show('privacy-policy');
|
||||
}
|
||||
|
||||
public function cookies(string $locale)
|
||||
{
|
||||
return $this->show('cookies-policy');
|
||||
}
|
||||
|
||||
private function show(string $slug)
|
||||
{
|
||||
$page = StoicPage::firstWhere('slug', $slug);
|
||||
|
||||
if (! $page) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return view('legal', ['page' => $page]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user