Feat: Updating COntrollers to remove business logic moved to boboko/core

This commit is contained in:
2026-09-03 11:47:38 +03:00
parent b87e22381f
commit b2207a622c
6 changed files with 56 additions and 50 deletions
+6 -11
View File
@@ -2,11 +2,14 @@
namespace App\Http\Controllers;
use App\Catalog\ProductCard;
use App\Models\StoicPage;
use Lunar\Models\Product;
use Modules\Core\Catalog\Services\ProductService;
class HomeController extends Controller
{
public function __construct(private readonly ProductService $products) {}
public function index(string $locale)
{
$page = StoicPage::firstWhere('slug', 'home');
@@ -15,16 +18,8 @@ public function index(string $locale)
abort(404);
}
$products = Product::with(['variants.prices.currency', 'media'])
->inRandomOrder()
->limit(13)
->get()
->map(fn (Product $product) => [
'name' => $product->translateAttribute('name'),
'price' => $product->variants->first()?->prices->first()?->price->decimal,
'image' => $product->media->first()?->getUrl(),
'href' => route('product.show', ['id' => $product->id]),
]);
$products = collect($this->products->random(13))
->map(fn (array $product) => ProductCard::fromIndexed($product));
return view('home', [
'page' => $page,