limit(3)->inRandomOrder()->get(); $newsModels = News::query()->where('published', true)->orderBy('created_at', 'desc')->limit(6)->get(); $staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->firstOrFail(); $klubBloc = KlubBloc::query()->first(); \throw_if(empty($klubBloc), 'empty klubBloc'); return view('fo.pages.home', compact('staticPageModel', 'rangeModels', 'klubBloc', 'newsModels')); } /** * unsubscribeNewsletter method * * @param \App\Http\Requests\Fo\UnsubscribeNewsletterRequest $request * @return \Illuminate\Contracts\View\View */ public function unsubscribeNewsletter(UnsubscribeNewsletterRequest $request): \Illuminate\Contracts\View\View { $error = null; $hashcode = $request->hashcode; try { SingleOptin::unsetStatusWithHashcode($hashcode); } catch (ApiErrorException $e) { Log::debug($e->getMessage()); if ($e->getApiError()->equals(ApiError::modelNotFound)) { if ($customer = Customer::find($hashcode)) { $customer->opt_in = false; // ! Les données peuvent être parsés en retour de la crm et inconsitantes (Héritage vielle crm). try { $customer->save(); } catch (ValidationException $e) { $error = null; } } else { abort(404); } } else { if (app()->bound('sentry')) { app('sentry')->captureException($e); } $error = true; } } catch (CrmException $e) { Log::debug($e->getMessage()); $error = true; if (app()->bound('sentry')) { app('sentry')->captureException($e); } } //end try if (!is_null($error)) { return view('fo.pages.newsletter-unsubscribe')->with( 'error', trans('Une erreur est survenue, merci de réessayer ultérieurement') ); } return view('fo.pages.newsletter-unsubscribe'); } }