Add shop email destination in form contact
This commit is contained in:
parent
825d47797b
commit
039587d1e3
9 changed files with 38 additions and 14 deletions
|
|
@ -40,6 +40,7 @@ class MagasinsController extends Controller
|
|||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email:rfc,dns,spoof|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'postcode' => 'required',
|
||||
'city' => 'required|string|max:255',
|
||||
|
|
@ -73,6 +74,7 @@ class MagasinsController extends Controller
|
|||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email:rfc,dns,spoof|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'postcode' => 'required',
|
||||
'city' => 'required|string|max:255',
|
||||
|
|
|
|||
|
|
@ -25,11 +25,12 @@ class ContactController extends Controller
|
|||
// @phpcs:enable
|
||||
$status = $request->session()->get('status');
|
||||
|
||||
// 1er magasin en base pour le moment
|
||||
$magasin = Magasin::first();
|
||||
$magasin = Magasin::first();
|
||||
$magasins = Magasin::all();
|
||||
|
||||
$content = Content::where('key', 'contact')->first();
|
||||
|
||||
return view('contact', compact('status', 'magasin', 'content'));
|
||||
return view('contact', compact('status', 'magasins', 'magasin', 'content'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -42,12 +43,20 @@ class ContactController extends Controller
|
|||
{
|
||||
$data = $request->all();
|
||||
|
||||
$toMailSetting = Setting::where('key', 'send_contact_mail_to')->first();
|
||||
if (empty($toMailSetting->value)) {
|
||||
$toMail = config('mail.from.address');
|
||||
/** @var Magasin|null */
|
||||
$shop = Magasin::where('name', $request->shop)->first();
|
||||
|
||||
if ($shop) {
|
||||
$toMail = $shop->email;
|
||||
} else {
|
||||
$toMail = $toMailSetting->value;
|
||||
$toMailSetting = Setting::where('key', 'send_contact_mail_to')->first();
|
||||
if (empty($toMailSetting->value)) {
|
||||
$toMail = config('mail.from.address');
|
||||
} else {
|
||||
$toMail = $toMailSetting->value;
|
||||
}
|
||||
}
|
||||
|
||||
// Envoi du mail d'alerte.
|
||||
Mail::to($toMail)->send(new SendContactMail($request));
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class ContactFormRequest extends FormRequest
|
|||
'last_name' => 'required|min:2',
|
||||
'first_name' => 'required|min:2',
|
||||
'email' => 'required|email:rfc,dns,spoof',
|
||||
'shop' => 'sometimes',
|
||||
'subject' => 'required|min:2',
|
||||
'order_ref' => 'sometimes',
|
||||
'message' => 'required|min:20|max:1900',
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Magasin extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'address', 'postcode', 'city', 'phone',
|
||||
'name', 'email', 'address', 'postcode', 'city', 'phone',
|
||||
'latitude', 'longitude',
|
||||
'gmaps_placeid', 'gmaps_embed_href', 'gmaps_link_href',
|
||||
];
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class CreateMagasinsTable extends Migration
|
|||
Schema::create('magasins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('address');
|
||||
$table->string('postcode');
|
||||
$table->string('city');
|
||||
|
|
|
|||
|
|
@ -14,13 +14,14 @@ class MagasinsSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
$shop = new Magasin();
|
||||
$shop->name = 'Point de retrait';
|
||||
$shop->address = 'l\'adresse';
|
||||
$shop->postcode = '72000';
|
||||
$shop->city = 'Le Mans';
|
||||
$shop = new Magasin();
|
||||
$shop->name = 'Point de retrait';
|
||||
$shop->email = 'adresse@domaine.fr';
|
||||
$shop->address = 'l\'adresse';
|
||||
$shop->postcode = '72000';
|
||||
$shop->city = 'Le Mans';
|
||||
$shop->gmaps_embed_href = "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d5338.425979915083!2d0.1977634707405403!3d48.00959481914027!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x47e288cfcdc1a263%3A0x7acf6d8dc923c25a!2zQ2l0w6kgUGxhbnRhZ2Vuw6p0!5e0!3m2!1sfr!2sfr!4v1619612657653!5m2!1sfr!2sfr";
|
||||
$shop->gmaps_link_href = 'https://goo.gl/maps/sxuj7FevRSHsDb8MA';
|
||||
$shop->gmaps_link_href = 'https://goo.gl/maps/sxuj7FevRSHsDb8MA';
|
||||
$shop->save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@
|
|||
<label for="name">Nom *</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Nom *" value="{{ old('name') }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Email de contact *</label>
|
||||
<input type="text" id="email" name="email" class="form-control" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" placeholder="adresse@pole-sbv.fr *" value="{{ old('email') }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Adresse *</label>
|
||||
<input type="text" id="address" name="address" class="form-control" placeholder="Adresse *" value="{{ old('address') }}" required>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@
|
|||
<a class="btn btn-sm btn-primary" href="{{route('bo.creneaux.settings', $magasin->id)}}">Editer Créneaux de collecte</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Email de contact *</label>
|
||||
<input type="text" id="email" name="email" class="form-control" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" placeholder="adresse@pole-sbv.fr *" value="{{ old('email',$magasin->email) }}" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Adresse *</label>
|
||||
<input type="text" id="address" name="address" class="form-control" placeholder="Adresse *" value="{{ old('address',$magasin->address) }}" required>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<thead>
|
||||
<th scope="col"></th>
|
||||
<th scope="col">Nom</th>
|
||||
<th scope="col">Email</th>
|
||||
<th scope="col">Adresse</th>
|
||||
<th scope="col">Téléphone</th>
|
||||
<th scope="col"></th>
|
||||
|
|
@ -24,6 +25,7 @@
|
|||
<tr>
|
||||
<td></td>
|
||||
<td>{{$magasin->name}}</td>
|
||||
<td>{{$magasin->email}}</td>
|
||||
<td>{{$magasin->address}}, {{$magasin->postcode}} {{$magasin->city}}</td>
|
||||
<td>{{$magasin->phone}}</td>
|
||||
<td class="text-center">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue