session()->get('status'); $magasin = Magasin::first(); $magasins = Magasin::all(); $content = Content::where('key', 'contact')->first(); return view('contact', compact('status', 'magasins', 'magasin', 'content')); } /** * submit contact form * * @param ContactFormRequest $request * @return \Illuminate\Http\Response * @throws \RuntimeException If email missing. */ public function contactSubmit(ContactFormRequest $request) { /** @var \App\Model\Magasin|null */ $shop = Magasin::where('name', $request->shop)->first(); if ($shop and $shop->email_contact) { /** @var string */ $toMail = $shop->email_contact; } else { /** @var string|null */ $toMail = \optional(Setting::where('key', 'send_contact_mail_to')->first())->value; if (!$toMail) { /** @var string|null */ $toMail = config('mail.from.address'); } } if (!$toMail) { throw new \RuntimeException('Impossible de trouver un mail'); } // Envoi du mail d'alerte. Mail::to($toMail)->send(new SendContactMail($request)); return back()->with('status', true); } }