2026-08-08 14:50:10 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2026-09-03 11:47:38 +03:00
|
|
|
use App\Catalog\ProductCard;
|
2026-08-26 13:43:30 +03:00
|
|
|
use App\Models\StoicPage;
|
2026-09-03 11:47:38 +03:00
|
|
|
use Modules\Core\Catalog\Services\ProductService;
|
2026-08-08 14:50:10 +03:00
|
|
|
|
|
|
|
|
class HomeController extends Controller
|
|
|
|
|
{
|
2026-09-03 11:47:38 +03:00
|
|
|
public function __construct(private readonly ProductService $products) {}
|
|
|
|
|
|
2026-08-26 13:43:30 +03:00
|
|
|
public function index(string $locale)
|
2026-08-08 14:50:10 +03:00
|
|
|
{
|
2026-08-26 13:43:30 +03:00
|
|
|
$page = StoicPage::firstWhere('slug', 'home');
|
|
|
|
|
|
|
|
|
|
if (! $page) {
|
|
|
|
|
abort(404);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-03 11:47:38 +03:00
|
|
|
$products = collect($this->products->random(13))
|
|
|
|
|
->map(fn (array $product) => ProductCard::fromIndexed($product));
|
2026-08-08 14:50:10 +03:00
|
|
|
|
|
|
|
|
return view('home', [
|
2026-08-26 13:43:30 +03:00
|
|
|
'page' => $page,
|
2026-08-08 14:50:10 +03:00
|
|
|
'heroProducts' => $products->take(5)->values(),
|
|
|
|
|
'classicsProducts' => $products->slice(5)->values(),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|