value], ['status', 1] ])->orderBy('order', 'ASC')->get(); $newsSlides = NewsSliderPictures::where('status', 1)->orderBy('order', 'ASC')->get(); // Images d'éleveur. $breeder = OCBBreeder::ocbValidated()->select('picture', 'first_name', 'last_name') ->inRandomOrder()->first(); // Les produits star. $starProducts = Products::select('picture', 'name', 'slug')->where([['star', 1], ['status', 1]]) ->inRandomOrder()->limit(3)->get(); if ($starProducts->count() < 3) { $starProducts = $starProducts->concat(Products::select('picture', 'name', 'slug') ->where([['star', 0], ['status', 1]])->inRandomOrder()->limit(3 - $starProducts->count())->get()); } // Montant réductions. $montantReduction = Reduction::whereStatus(true)->sum('value'); return view('home', compact('slides', 'newsSlides', 'breeder', 'starProducts', 'montantReduction')); } /** * Call the CRM to add a single optin * * @param \App\Http\Requests\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 __("Votre inscription à la newsletter a été prise en compte"); } 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'); } if (app()->bound('sentry')) { app('sentry')->captureException($e); } return trans('Une erreur est survenue, merci de réessayer ultérieurement'); } catch (CrmException $e) { if (app()->bound('sentry')) { app('sentry')->captureException($e); } return trans('Une erreur est survenue, merci de réessayer ultérieurement'); } } /** * joinUs * * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory */ public function joinUs() { return view('front.joinus', ['joinus' => PageJoinus::firstOrFail()]); } }