user(); $crmCustomer = $customer->api_data; return view('theme::auth.profil-verify', compact('crmCustomer')); } /** * Profile verify * * @param \App\Http\Requests\Fo\Customers\VerifyInformationsRequest $request * @return \Illuminate\Http\RedirectResponse * @throws IlluminateValidationException In case of any error validation or within the crm. */ public function profilVerifySubmit(VerifyInformationsRequest $request): RedirectResponse { // ! Pas de Gate/Policies Ici volontairement, vu avec Vincent try { return DB::transaction(function () use ($request) { // * --- FILL AND SAVE CUSTOMER /** @var \App\Models\Customer */ $customer = auth('frontend')->user(); // * Màj, on ne mets pas à jour le mdp ou l'adresse email, juste les champs pour mesBr $customer->updateApiData(\array_merge(Arr::only( $request->validated(), [ 'firstname', 'lastname', 'birth_date', 'address', 'country', 'city', 'phone', 'email', 'password', 'opt_in', ] ), ['postcode' => $request->input('postal_code')])); Session::flash('success', trans('Vos informations ont bien été mis à jour')); return response()->redirectToRoute('fo.participate'); }); } catch (CrmValidationException $e) { // * Local Validation failure throw IlluminateValidationException::withMessages([ 'error' => $e->getMessage() ]); } catch (ApiErrorException $e) { if ($e->getApiError()->equals(ApiError::validationFailed())) { throw IlluminateValidationException::withMessages([ 'error' => $e->getMessage() ]); } report($e); Log::error(__CLASS__ . '::update reached end of possibilities.'); } catch (CrmException $e) { report($e); Log::error(__CLASS__ . '::error occured on calling crm.'); throw IlluminateValidationException::withMessages([ 'error' => trans('Une erreur est survenue, veuillez réssayer plus tard') ]); } //end try return back()->withInput()->withErrors(trans('Une erreur est survenue, merci de réessayer ultérieurement.')); } /** * View all customer winnig participations * * @return \Illuminate\Contracts\View\View */ public function viewWinningParticipations(): View { $this->authorize('viewWonList', \App\Models\Participation::class); /** @var \App\Models\Customer */ $customer = auth('frontend')->user(); $winningList = $customer->participations() ->with(['instantWin', 'discount'])->where(function (Builder $q) { $q->whereHas('instantWin')->orWhereHas('discount'); })->get(); return view('theme::pages.participation.winning-participations', compact('winningList')); } }