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 String $email Email to add as a single optin * @return String Message to print to the customer */ 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'); } Utils::sendEmailErrorManually($e); return trans('Une erreur est survenue, merci de réessayer ultérieurement'); } catch (CrmException $e) { Utils::sendEmailErrorManually($e); return trans('Une erreur est survenue, merci de réessayer ultérieurement'); } } public function joinUs() { return view('front.joinus', ['joinus' => PageJoinus::firstOrFail()]); } }