19 lines
547 B
PHP
19 lines
547 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Category;
|
|
use App\Models\Product;
|
|
|
|
class HomepageController extends Controller
|
|
{
|
|
public function __invoke()
|
|
{
|
|
return inertia('homepage', [
|
|
'categories' => Category::all(),
|
|
'bestSellers' => Product::with(['categories', 'prices'])->active()->latest()->take(4)->get(),
|
|
'topSellingProducts' => Product::with(['categories', 'prices'])->withCount('orderItems')->active()->orderBy('order_items_count', 'desc')->take(3)->get(),
|
|
]);
|
|
}
|
|
}
|