where('type', StaticPageType::home)->first(); $mainSlideModels = MainSlide::query()->where('published', true)->orderBy('order', 'ASC')->with('approach')->get(); $demarcheSlideModels = DemarcheSlide::query()->where('published', true)->orderBy('order', 'ASC')->get(); $rangeModels = Range::query()->where('published', true)->orderBy('slug', 'ASC')->get(); $productViews = Product::getProductsViewsByRange(); $hotNewsSettings = GeneralSetting::query()->where('type', SettingsType::hotNews)->first(); $newsModels = News::query()->where('published', true)->with('newsCategory')->get(); $recipeModels = Recipe::query()->where('published', true)->with([ 'products', 'products.meat', 'products.submeat', 'consumptionMoment' ])->limit(9)->get(); $videoModels = Video::query()->where('published', true)->where('is_on_homepage', true) ->orderBy('order', 'ASC')->with('product')->limit(9)->get(); return view('fo.pages.home', compact( 'staticPageModel', 'mainSlideModels', 'rangeModels', 'demarcheSlideModels', 'productViews', 'newsModels', 'recipeModels', 'hotNewsSettings', 'videoModels' )); } /** * Call the CRM to add a single optin * * @param \App\Http\Requests\Fo\SingleOptinRequest $request * @return string|array|null|\Illuminate\Contracts\Translation\Translator * @throws \LDC\LDCCRM\Exceptions\ValidationException ValidationException. * @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException. */ public function addOptIn(SingleOptinRequest $request) { try { SingleOptin::setStatus($request->email, true); return \response(trans("Votre inscription à la newsletter a été prise en compte"), 200); } catch (ApiErrorException $e) { // Il y a deja un customerInfo avec optin a true pour ce customer. if ($e->getApiError()->equals(ApiError::singleOptinCustomerExists)) { return trans('Vous êtes déjà inscrit avec cette adresse email'); } \report($e); return \response(trans('Une erreur est survenue, merci de réessayer ultérieurement'), 404); } catch (CrmException $e) { \report($e); return \response(trans('Une erreur est survenue, merci de réessayer ultérieurement'), 404); } } /** * Display a listing of the resource. * * @return \Illuminate\Http\JsonResponse */ public function updateHotNewsSatus(): \Illuminate\Http\JsonResponse { Cache::put('hotNewsIsDisplayed', true, now()->addHours(24)); return response()->json(); } }