From 11dad23fe2cb8c843f580f2778a1481ec5e8f54e Mon Sep 17 00:00:00 2001 From: "S. Hattry" Date: Fri, 25 Nov 2022 14:42:18 +0100 Subject: [PATCH] Add confirm admin email according to shop --- app/Http/Controllers/Bo/MagasinsController.php | 6 ++++-- app/Http/Controllers/Bo/OrdersController.php | 17 ++++++++++++----- app/Http/Controllers/ContactController.php | 4 ++-- app/Http/Controllers/CustomerController.php | 2 +- app/Models/Magasin.php | 2 +- .../2022_11_25_094244_add_field_to_magasins.php | 6 ++++-- database/seeders/MagasinsSeeder.php | 2 +- resources/views/bo/magasins/create.blade.php | 16 +++++++++++++--- resources/views/bo/magasins/edit.blade.php | 16 +++++++++++++--- resources/views/bo/magasins/index.blade.php | 6 ++++-- 10 files changed, 55 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/Bo/MagasinsController.php b/app/Http/Controllers/Bo/MagasinsController.php index 9c450d1..f08d312 100644 --- a/app/Http/Controllers/Bo/MagasinsController.php +++ b/app/Http/Controllers/Bo/MagasinsController.php @@ -40,7 +40,8 @@ class MagasinsController extends Controller { $request->validate([ 'name' => 'required|string|max:255', - 'email' => 'required|email:rfc,dns,spoof|max:255', + 'email_contact' => 'required|email:rfc,dns,spoof|max:255', + 'email_confirm' => 'nullable|email:rfc,dns,spoof|max:255', 'address' => 'required|string|max:255', 'postcode' => 'required', 'city' => 'required|string|max:255', @@ -74,7 +75,8 @@ class MagasinsController extends Controller { $request->validate([ 'name' => 'required|string|max:255', - 'email' => 'required|email:rfc,dns,spoof|max:255', + 'email_contact' => 'required|email:rfc,dns,spoof|max:255', + 'email_confirm' => 'nullable|email:rfc,dns,spoof|max:255', 'address' => 'required|string|max:255', 'postcode' => 'required', 'city' => 'required|string|max:255', diff --git a/app/Http/Controllers/Bo/OrdersController.php b/app/Http/Controllers/Bo/OrdersController.php index 6b079c1..e9460f4 100644 --- a/app/Http/Controllers/Bo/OrdersController.php +++ b/app/Http/Controllers/Bo/OrdersController.php @@ -494,7 +494,6 @@ class OrdersController extends Controller 'ok_cgv' => 'accepted', ]); - $time_slot = Carbon::createFromFormat('d/m/Y-H:i', $request->selectedcreneau); $tsday = explode('-', $request->selectedcreneau)[0]; $tstime = explode('-', $request->selectedcreneau)[1]; $magasin_id = $request->selectedmagasin; @@ -519,12 +518,20 @@ class OrdersController extends Controller Mail::to($order->customer->email)->queue(new OrderConfirmMail($order)); // Envoi du mail de confirmation aux admins site. - $toMailSetting = Setting::where('key', 'send_order_confirm_mail_to')->first(); - if (empty($toMailSetting->value)) { - $toMail = config('mail.from.address'); + /** @var Magasin|null */ + $shop = Magasin::where('id', $magasin_id)->first(); + + if ($shop && $shop->email_confirm) { + $toMail = $shop->email_confirm; } else { - $toMail = $toMailSetting->value; + $toMailSetting = Setting::where('key', 'send_order_confirm_mail_to')->first(); + if (empty($toMailSetting->value)) { + $toMail = config('mail.from.address'); + } else { + $toMail = $toMailSetting->value; + } } + Mail::to($toMail)->queue(new OrderConfirmAdminMail($order)); // Export commande. diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index 038c69b..7409112 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -46,8 +46,8 @@ class ContactController extends Controller /** @var Magasin|null */ $shop = Magasin::where('name', $request->shop)->first(); - if ($shop) { - $toMail = $shop->email; + if ($shop && $shop->email_contact) { + $toMail = $shop->email_contact; } else { $toMailSetting = Setting::where('key', 'send_contact_mail_to')->first(); if (empty($toMailSetting->value)) { diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index c019f5f..c6f9185 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -469,7 +469,7 @@ class CustomerController extends Controller $order->status_id = 7; $order->save(); - // Envoi du mail de confirmation aux admins site. + // Envoi du mail d'annulation aux admins site. $toMailSetting = Setting::where('key', 'send_order_confirm_mail_to')->first(); if (empty($toMailSetting->value)) { $toMail = config('mail.from.address'); diff --git a/app/Models/Magasin.php b/app/Models/Magasin.php index 596e2bb..a9236e5 100644 --- a/app/Models/Magasin.php +++ b/app/Models/Magasin.php @@ -15,7 +15,7 @@ class Magasin extends Model * @var array */ protected $fillable = [ - 'name', 'email', 'address', 'postcode', 'city', 'phone', + 'name', 'email_contact', 'email_confirm', 'address', 'postcode', 'city', 'phone', 'latitude', 'longitude', 'gmaps_placeid', 'gmaps_embed_href', 'gmaps_link_href', ]; diff --git a/database/migrations/2022_11_25_094244_add_field_to_magasins.php b/database/migrations/2022_11_25_094244_add_field_to_magasins.php index 59a02da..aeedb87 100644 --- a/database/migrations/2022_11_25_094244_add_field_to_magasins.php +++ b/database/migrations/2022_11_25_094244_add_field_to_magasins.php @@ -14,7 +14,8 @@ class AddFieldToMagasins extends Migration public function up() { Schema::table('magasins', function (Blueprint $table) { - $table->string('email')->after('name'); + $table->string('email_contact')->after('name'); + $table->string('email_confirm')->nullable()->after('email_contact'); }); } @@ -26,7 +27,8 @@ class AddFieldToMagasins extends Migration public function down() { Schema::table('magasins', function (Blueprint $table) { - $table->dropColumn('email'); + $table->dropColumn('email_contact'); + $table->dropColumn('email_confirm'); }); } } diff --git a/database/seeders/MagasinsSeeder.php b/database/seeders/MagasinsSeeder.php index d6f4e4a..0468cbb 100644 --- a/database/seeders/MagasinsSeeder.php +++ b/database/seeders/MagasinsSeeder.php @@ -16,7 +16,7 @@ class MagasinsSeeder extends Seeder { $shop = new Magasin(); $shop->name = 'Point de retrait'; - $shop->email = 'adresse@domaine.fr'; + $shop->email_contact = 'adresse@domaine.fr'; $shop->address = 'l\'adresse'; $shop->postcode = '72000'; $shop->city = 'Le Mans'; diff --git a/resources/views/bo/magasins/create.blade.php b/resources/views/bo/magasins/create.blade.php index 849b3c6..db19cfb 100644 --- a/resources/views/bo/magasins/create.blade.php +++ b/resources/views/bo/magasins/create.blade.php @@ -22,9 +22,19 @@ -
- - +
+
+
+ + +
+
+
+
+ + +
+
diff --git a/resources/views/bo/magasins/edit.blade.php b/resources/views/bo/magasins/edit.blade.php index feca979..0b768aa 100644 --- a/resources/views/bo/magasins/edit.blade.php +++ b/resources/views/bo/magasins/edit.blade.php @@ -31,9 +31,19 @@ Editer Créneaux de collecte
-
- - +
+
+
+ + +
+
+
+
+ + +
+
diff --git a/resources/views/bo/magasins/index.blade.php b/resources/views/bo/magasins/index.blade.php index c247f70..6698fe2 100644 --- a/resources/views/bo/magasins/index.blade.php +++ b/resources/views/bo/magasins/index.blade.php @@ -15,7 +15,8 @@ Nom - Email + Email de contact + Email de confirmation
de commande Adresse Téléphone @@ -25,7 +26,8 @@ {{$magasin->name}} - {{$magasin->email}} + {{$magasin->email_contact}} + {{$magasin->email_confirm}} {{$magasin->address}}, {{$magasin->postcode}} {{$magasin->city}} {{$magasin->phone}}