contact page, legal pages and category page

This commit is contained in:
elvira
2026-08-26 13:43:30 +03:00
parent 45057f9083
commit fab9cc08a8
38 changed files with 1726 additions and 182 deletions
@@ -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');
}
}
+9 -1
View File
@@ -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]);
}
}