first(); $slider = Slider::where('published', 1)->first(); if ($slider) { $slides = Slide::whereHas('slider', function ($q) use ($slider) { $q->whereId($slider->id); })->where(function ($q) { $q->where( function ($q) { $q->where('date_start', '<=', Carbon::now()->format('Y-m-d H:i:s')) ->where('date_end', '>', Carbon::now()->format('Y-m-d H:i:s')); } )->orWhere(function ($q) { $q->whereNull('date_start') ->whereNull('date_end'); }); })->orderBy('order', 'ASC') ->get(); } else { $slides = null; } $encart_home = Encart::where('page', Page::homeHeader()->value)->first(); $post_home = Post::where([ ['date_start', '<=', Carbon::now()->format('Y-m-d H:i:s')], ['date_end', '>', Carbon::now()->format('Y-m-d H:i:s')], ['on_top', true] ])->first(); // Limitation à 3 produits affichés sur la homepage $products_home = Product::where('is_on_top', true)->take(3)->get(); return view('front.home', compact('slider', 'slides', 'seoDatum', 'encart_home', 'post_home', 'products_home')); } }