This commit is contained in:
58
app/Http/Controllers/Shop/ShopController.php
Normal file
58
app/Http/Controllers/Shop/ShopController.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Category;
|
||||
use App\Models\HomeSlide;
|
||||
use App\Models\Product;
|
||||
|
||||
class ShopController extends Controller
|
||||
{
|
||||
public function home()
|
||||
{
|
||||
$categories = Category::query()
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->take(12)
|
||||
->get();
|
||||
|
||||
$featured = Product::query()
|
||||
->where('is_active', true)
|
||||
->where('stock', '>', 0)
|
||||
->with('category')
|
||||
->orderByDesc('stock')
|
||||
->orderByDesc('id')
|
||||
->take(12)
|
||||
->get();
|
||||
|
||||
$newProducts = Product::query()
|
||||
->where('is_active', true)
|
||||
->where('stock', '>', 0)
|
||||
->with('category')
|
||||
->orderByDesc('created_at')
|
||||
->orderByDesc('id')
|
||||
->take(12)
|
||||
->get();
|
||||
|
||||
$leftSlides = HomeSlide::query()
|
||||
->active()
|
||||
->forZone('left')
|
||||
->ordered()
|
||||
->get();
|
||||
|
||||
$rightSlides = HomeSlide::query()
|
||||
->active()
|
||||
->forZone('right')
|
||||
->ordered()
|
||||
->get();
|
||||
|
||||
return view('shop.home', [
|
||||
'categories' => $categories,
|
||||
'featured' => $featured,
|
||||
'newProducts' => $newProducts,
|
||||
'leftSlides' => $leftSlides,
|
||||
'rightSlides' => $rightSlides,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user