From 9ecb97bbfa59604a67594de57976141b8e20b2b9 Mon Sep 17 00:00:00 2001 From: Olivier Legat Date: Thu, 25 Mar 2021 17:59:02 +0100 Subject: [PATCH] inscription setup --- app/Http/Controllers/CustomerController.php | 339 ++++++++++++++++++ app/Http/Requests/CustomerRegisterRequest.php | 56 +++ app/Lib/LDCCRM/ApiV1.php | 189 ++++++++++ app/Mail/PasswordResetMail.php | 38 ++ app/Mail/RegisterConfirmMail.php | 40 +++ app/Models/Customers.php | 97 +++++ app/Providers/CrmApiServiceProvider.php | 22 ++ config/app.php | 1 + config/auth.php | 10 + config/crm.php | 8 + ...21_02_04_175136_create_customers_table.php | 41 +++ .../front/canard/auth/register.blade.php | 43 ++- .../canard/mails/password-reset.blade.php | 71 ++++ .../front/canard/mails/register-ok.blade.php | 87 +++++ .../canard/partials/products-list.blade.php | 2 +- .../views/front/canard/product.blade.php | 2 +- routes/web.php | 19 +- 17 files changed, 1057 insertions(+), 8 deletions(-) create mode 100644 app/Http/Controllers/CustomerController.php create mode 100644 app/Http/Requests/CustomerRegisterRequest.php create mode 100644 app/Lib/LDCCRM/ApiV1.php create mode 100644 app/Mail/PasswordResetMail.php create mode 100644 app/Mail/RegisterConfirmMail.php create mode 100644 app/Models/Customers.php create mode 100644 app/Providers/CrmApiServiceProvider.php create mode 100644 config/crm.php create mode 100644 database/migrations/2021_02_04_175136_create_customers_table.php create mode 100644 resources/views/front/canard/mails/password-reset.blade.php create mode 100644 resources/views/front/canard/mails/register-ok.blade.php diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php new file mode 100644 index 0000000..c483a49 --- /dev/null +++ b/app/Http/Controllers/CustomerController.php @@ -0,0 +1,339 @@ +check()) { + return redirect()->route('home'); + } + return view('auth.register'); + } + + /** + * Enregistre le customer dans la base de données + */ + public function register(CustomerRegisterRequest $request) + { + /** @var \App\Lib\LDCCRM\ApiV1 */ + $crm = app('crmApi'); + $crmCustomer = $crm->createCustomer( + $request->email, + $request->password, + $request->firstname, + $request->lastname, + $request->optin !== null ? 1 : 0, + $birthDate = Carbon::createFromDate( + $request->year, + $request->month, + $request->day + )->format('Y-m-d'), + isset($phone) ? $phone : null, + isset($address) ? $address : null, + null, + $request->city, + $request->postcode, + null + ); + + if ($crmCustomer->status === "OK") { + $customer = new Customers($request->all()); + $customer->crm_id = $crmCustomer->user->crm_id; + $customer->hashcode = $crmCustomer->user->hashcode; + $customer->save(); + + Mail::to($request->email)->send(new RegisterConfirmMail($customer, $request->firstname)); + + return view('front.auth.confirm-register'); + } else { + switch ($crmCustomer->code) { + case 102: + return back()->withInput()->withErrors( + "Les champs obligatoires n'ont pas été correctement remplis." + ); + case 103: + return back()->withInput()->withErrors( + "Un compte est déjà associé à cette adresse email." + ); + default: + return back()->withInput()->withErrors( + "Une erreur est survenue lors de l'inscription, merci de réessayer plus tard." + ); + } + } + } + + /** + * Retourne la page de connexion + */ + public function authenticateForm(Request $request) + { + if (Auth::guard('customer')->check()) { + return redirect()->route('home'); + } + if ($request->get('url')) { + Session::put('url.intended', $request->get('url')); + Session::save(); + } + return view('front.auth.login'); + } + + /** + * Gère l'authentification des customers + */ + public function authenticate(Request $request) + { + $request->validate([ + 'email' => 'required|email:rfc', + 'password' => 'required', + ]); + + $email = filter_var($request->email, FILTER_SANITIZE_EMAIL); + $password = $request->password; + $remember = $request->remember !== null ? true : false; + + /** @var Customers */ + $customer = Customers::where('email', $email)->first(); + if ($customer) { + /** @var \App\Lib\LDCCRM\ApiV1 */ + $crm = app('crmApi'); + $result = $crm->loginCustomer($email, $password); + if ($result->status === "OK") { + /** @var \Illuminate\Auth\SessionGuard */ + $guard = Auth::guard('customer'); + $guard->login($customer, $remember); + $url = Session::pull('url.intended'); + Session::forget('url.intended'); + Session::save(); + return redirect()->to($url); + } else { + switch ($result->code) { + case 115: + return back()->withErrors("Veuillez vérifier que vous avez correctement rempli les champs obligatoires."); + case 116: + Mail::to($email)->send(new RegisterConfirmMail($customer, null)); + return back()->withErrors("Votre compte n'est pas activé, vérifier dans vos emails pour y trouver le mail de confirmation. Un lien d'activation vous a été renvoyer."); + case 117 || 118 || 119: + return back()->withErrors("Email ou mot de passe incorrect."); + default: + return back()->withErrors("Une erreur est survenue, merci de réessayer ultérieurement."); + } + } + } else { + return back()->withErrors("Email ou mot de passe incorrect."); + } + } + + /** + * Active le compte d'un customer + */ + public function activate($hashcode) + { + $hashcode = filter_var($hashcode, FILTER_SANITIZE_STRING); + $customer = Customers::select('crm_id')->where('hashcode', $hashcode)->first(); + if ($customer) { + /** @var \App\Lib\LDCCRM\ApiV1 */ + $crm = app('crmApi'); + $result = $crm->activateCustomer($customer->crm_id); + if ($result->status === "OK") { + return view('front.auth.activate')->with('message', 'Votre compte a bien été activé, vous pouvez désormais vous connecter.'); + } else { + return view('front.auth.activate')->with('message', "Ce lien d'activation n'est pas valide."); + } + } else { + return view('front.auth.activate')->with('message', "Ce lien d'activation n'est pas valide."); + } + } + + public function logout() + { + if (Auth::guard('customer')->check()) { + Auth::guard('customer')->logout(); + return redirect()->route('home'); + } + } + + public function passwordReset(Request $request) + { + $request->validate([ + 'email' => 'required|email:rfc|max:255', + ]); + + $email = filter_var($request->email, FILTER_SANITIZE_EMAIL); + + $customerExist = Customers::where('email', $email)->count() === 0 ? false : true; + + if ($customerExist) { + // Suppression des anciens tokens + PasswordReset::where('email', $email)->delete(); + + $token = Str::random(80); + + $passwordReset = new PasswordReset(); + $passwordReset->email = $email; + $passwordReset->token = $token; + $passwordReset->created_at = now(); + $passwordReset->save(); + + Mail::to($email)->send(new PasswordResetMail($token)); + return back()->with('success', __("La procédure pour changer votre mot de passe a été envoyé sur votre email.")); + } else { + return back()->withErrors(__("Cette adresse email n'est pas enregistrée dans nos services.")); + } + } + + /** + * Print the view used to change the password of a user when he required it + * @param $token Token used to identificate the user to change the password of + * @return View The view to print + */ + public function viewChangePassword($token) + { + $pwdReset = PasswordReset::where('token', $token)->first(); + if (!$pwdReset) { + abort(419); + } + $customer = Customers::where('email', $pwdReset->email)->first(); + if (!$customer) { + abort(404); + } + + return view('front.auth.password-reset', compact('customer'))->with('token', $token); + } + + public function changePassword(Request $request, $token) + { + $request->validate([ + 'password' => 'required|confirmed|min:8|max:255' + ]); + + $password = $request->password; + + try { + $passwordReset = PasswordReset::where('token', $token)->first(); + $customer = Customers::where('email', $passwordReset->email)->first(); + $crmId = $customer->crm_id; + } catch (Exception $e) { + return back()->withErrors("Changement du mot de passe impossible, les données envoyés sont incorrectes."); + } + /** @var \App\Lib\LDCCRM\ApiV1 */ + $crm = app('crmApi'); + $result = $crm->changePwdCustomer($crmId, $password); + if ($result->status === "OK") { + $passwordReset->delete(); + return view('front.auth.password-reset-ok', compact('customer')); + } else { + switch ($result->code) { + case 107: + return back()->withErrors("Veuillez vérifier que vous avez correctement rempli les champs obligatoires."); + case 108 || 109: + return back()->withErrors("Changement impossible, compte inexistant."); + default: + return back()->withErrors("Une erreur est survenue, merci de réessayer ultérieurement."); + } + } + } + + public function changePasswordWhenAuthenticated(Request $request) + { + $request->validate([ + 'password' => 'required|min:8|confirmed|max:255' + ]); + + $crm = app('crmApi'); + $customer = $crm->changePwdCustomer(Auth::guard('customer')->user()->crm_id, $request->password); + + if ($customer->status === "OK") { + return back()->with('success', __("Modifications enregistrés !")); + } else { + return back()->withErrors(__("Une erreur est survenue, merci de réessayer ultérieurement.")); + } + } + + public function changeOptin($token) + { + // TODO : Route et test de la méthode avec nouveau client CRM pour l'opt in + die("Attente"); + $crmId = Customers::where('hashcode', $token)->first()->crm_id; + + /** @var \App\Lib\LDCCRM\ApiV1 */ + $crm = app('crmApi'); + $result = $crm->toggleOptInCustomer($crmId); + if ($result->status === "OK") { + dd("OK"); + return back()->with('success', 'Modification enregistrée !'); + } else { + switch ($result->code) { + case 113 || 114: + dd("KO 113 ou 114"); + return back()->withErrors("Mise à jour impossible, compte inexistant."); + default: + dd("KO default"); + return back()->withErrors("Une erreur est survenue, merci de réessayer ultérieurement."); + } + } + } + + public function setFavoriteRecipe(Recipes $recipe, bool $status) + { + /** @var Customer */ + $customer = Auth::guard('customer')->user(); + if ($status) { + $customer->recipes()->attach($recipe); + } else { + $customer->recipes()->detach($recipe); + } + return response()->json(); + } + + public function setItemInCart(Products $product, bool $status) + { + /** @var \App\Models\Customer */ + $customer = Auth::guard('customer')->user(); + if ($status) { + $customer->products()->attach($product); + } else { + $customer->products()->detach($product); + } + } + + public function delete($id) + { + // TODO : Implémenter la suppression lorsque la CRM sera prête pour le faire aussi + die('Not implemented yet'); + // Suppression d'un compte client + $customer = Customers::findOrFail($id); + $customer->recipes()->delete(); + $customer->products()->delete(); + $customer->answers()->delete(); + $customer->forums()->delete(); + + // TODO : Suppression via la CRM + + if (Auth::guard('customer')->user()->id === $customer->id) + Auth::guard('customer')->logout(); + $customer->delete(); + + return redirect()->route('home'); + } +} diff --git a/app/Http/Requests/CustomerRegisterRequest.php b/app/Http/Requests/CustomerRegisterRequest.php new file mode 100644 index 0000000..18a13da --- /dev/null +++ b/app/Http/Requests/CustomerRegisterRequest.php @@ -0,0 +1,56 @@ + 'required|email:rfc,dns,spoof|max:255', + 'username' => 'required|string|max:255|unique:customers,username', + 'firstname' => 'required|string|max:255', + 'lastname' => 'required|string|max:255', + 'day' => 'required|alpha_num|gt:0|lt:32', + 'month' => 'required|alpha_num|gt:0|lt:13', + 'year' => [ + 'required', 'alpha_num', 'gt:' . (date('Y') - 101), 'lt:' . (date('Y') + 1), + function ($attribute, $value, $fail) { + $birthDate = Carbon::createFromDate($this->year, $this->month, $this->day); + // @phpcs:ignore PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace + if ( + $birthDate->format('dmY') !== $this->day . $this->month . $this->year || + $birthDate > Carbon::now() + ) { + $fail(__('Veuillez entrer une date de naissance valide')); + } + } + ], + 'address' => 'sometimes|max:255', + 'phone' => 'sometimes|max:255', + 'city' => 'required|string|max:255', + 'postcode' => 'required', + 'password' => 'required|confirmed|min:8|max:255', + 'password' => 'required|confirmed|min:8|max:255', + 'optin' => 'sometimes', + ]; + } +} diff --git a/app/Lib/LDCCRM/ApiV1.php b/app/Lib/LDCCRM/ApiV1.php new file mode 100644 index 0000000..3764cc9 --- /dev/null +++ b/app/Lib/LDCCRM/ApiV1.php @@ -0,0 +1,189 @@ +endpoint = $endpoint; + $this->api_key = $api_key; + } + + public function getCustomer($id) + { + return $this->callAPI('GET', "/customer/id/$id"); + } + + public function getCustomerByEmail($email) + { + return $this->callAPI('GET', "/customer/email/$email"); + } + + public function createCustomer($email, $password, $firstname, $lastname, $optin, $birthdate = null, $phone = null, $address = null, $address2 = null, $city = null, $postcode = null, $country = null) + { + $user = [ + 'email' => $email, + 'password' => $password, + 'firstname' => $firstname, + 'lastname' => $lastname, + 'opt_in' => $optin, + 'birth_date' => $birthdate, + 'phone' => $phone, + 'address' => $address, + 'address2' => $address2, + 'city' => $city, + 'postcode' => $postcode, + 'country' => $country + ]; + return $this->callAPI('POST', '/customer/create', $user); + } + + public function updateCustomer($crmId, $firstname = null, $lastname = null, $optin = null, $birthdate = null, $phone = null, $address = null, $address2 = null, $city = null, $postcode = null, $country = null) + { + $user = []; + + if ($firstname !== null) { + $user['firstname'] = $firstname; + } + + if ($lastname !== null) { + $user['lastname'] = $lastname; + } + + if ($optin !== null) { + $user['opt_in'] = $optin; + } + + if ($birthdate !== null) { + $user['birth_date'] = $birthdate; + } + + if ($phone !== null) { + $user['phone'] = $phone; + } + + if ($address !== null) { + $user['address'] = $address; + } + + if ($address2 !== null) { + $user['address2'] = $address2; + } + + if ($city !== null) { + $user['city'] = $city; + } + + if ($postcode !== null) { + $user['postcode'] = $postcode; + } + + if ($country !== null) { + $user['country'] = $country; + } + + + return $this->callAPI('PUT', "/customer/$crmId", $user); + } + + public function deleteCustomer($id) + { + return $this->callAPI('DELETE', "/customer/$id"); + } + + public function changePwdCustomer($id, $password) + { + return $this->callAPI('POST', "/customer/$id/change-password", ['password' => $password]); + } + + public function activateCustomer($id) + { + return $this->callAPI('POST', "/customer/$id/activate"); + } + + public function toggleOptInCustomer($id) + { + return $this->callAPI('POST', "/customer/$id/toggle-optin"); + } + + public function loginCustomer($email, $password) + { + return $this->callAPI('POST', "/customer/login", ['email' => $email, 'password' => $password]); + } + + public function createSingleOptin($email) + { + return $this->callAPI('POST', '/single-optin', ['email' => $email]); + } + + public function ArcadiaOutgoingMail($crm_id, $fields, $type) + { + return $this->callAPI('POST', '/arcadia/outgoing-mail', ['crm_id' => $crm_id, 'fields' => json_encode($fields), 'type' => $type]); + } + + private function callAPI($method, $url, $data = false) + { + + if (strpos($this->endpoint, "dev")) { + if ($data !== false) { + $data = array_merge($data, ['api_token' => $this->api_key]); + } else { + $data = ['api_token' => $this->api_key]; + } + } + + $url = $this->endpoint . '/api/v1' . $url; + $curl = curl_init(); + switch ($method) { + case "POST": + curl_setopt($curl, CURLOPT_POST, 1); + if ($data) { + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + } + break; + case "PUT": + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); + if ($data) { + curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); + } + break; + case "DELETE": + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); + if ($data) { + curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); + } + break; + default: + if ($data) { + $url = sprintf("%s?%s", $url, http_build_query($data)); + } + } + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_COOKIESESSION, true); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + if (!strpos($this->endpoint, "dev")) { + curl_setopt($curl, CURLOPT_HTTPHEADER, array( + 'Accept: application/json', + 'Authorization: Bearer ' . $this->api_key + )); + } + + $result = curl_exec($curl); + + if (!curl_errno($curl)) { + $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + if (!in_array($http_code, [200, 201])) { + return (object) ['status' => 'KO', 'code' => 500, 'message' => 'Connection to API failed - Code HTTP : ' . $http_code]; + } + } else { + return (object) ['status' => 'KO', 'code' => 500, 'message' => 'Connection to API failed : ' . curl_error($curl)]; + } + + curl_close($curl); + return json_decode($result); + } +} diff --git a/app/Mail/PasswordResetMail.php b/app/Mail/PasswordResetMail.php new file mode 100644 index 0000000..6d3ccaf --- /dev/null +++ b/app/Mail/PasswordResetMail.php @@ -0,0 +1,38 @@ +token = $token; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + $token = $this->token; + $moment = Moments::where('status', 1)->orderBy('updated_at', 'DESC')->first(); + return $this->subject("Réinitialiser votre accès au Club Le Gaulois")->view('front.mails.password-reset', compact('token', 'moment')); + } +} diff --git a/app/Mail/RegisterConfirmMail.php b/app/Mail/RegisterConfirmMail.php new file mode 100644 index 0000000..70c9b65 --- /dev/null +++ b/app/Mail/RegisterConfirmMail.php @@ -0,0 +1,40 @@ +firstname = $firstname; + $this->customer = $customer; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + $customer = $this->customer; + $firstname = $this->firstname; + $slugMoment = Moments::where('star_moment', 1)->first()->slug; + return $this->subject("Confirmation d'inscription au Club Le Gaulois")->view('front.mails.register-ok', compact('customer', 'firstname', 'slugMoment')); + } +} diff --git a/app/Models/Customers.php b/app/Models/Customers.php new file mode 100644 index 0000000..6ecf552 --- /dev/null +++ b/app/Models/Customers.php @@ -0,0 +1,97 @@ + + */ + public function getApiDataAttribute() + { + /** @var \App\Lib\LDCCRM\ApiV1 */ + $crm = app('crmApi'); + $response = (object)$crm->getCustomer($this->crm_id); + switch ($response->status) { + case 'KO': + throw new CrmException(sprintf('Api call error %s', $response->message)); + case 'OK': + return $response->user; + default: + throw new CrmException('Unknown status'); + } + } + + /** + * Set the crm Data of a customer + * + * @throws CrmException + * @return object crm user + * @author Jérémy Munsch + */ + public function updateApiData(CustomerCrmResource $resource) + { + /** @var \App\Lib\LDCCRM\ApiV1 */ + $crm = app('crmApi'); + $response = (object) \call_user_func_array([$crm, 'updateCustomer'], $resource->toArray(null)); + switch ($response->status) { + case 'KO': + throw new CrmException(sprintf('Api call error %s', $response->message)); + case 'OK': + return $response->user; + default: + throw new CrmException('Unknown status'); + } + } + + /** + * This mutate Customer attributes to array + * including only non critical properties and crm values + * (One that can be send to front office without security breach) + * + * @return array + */ + public function toArray() + { + if ($this->crm_id) { + return collect(array_merge( + parent::toArray(), + (array)$this->apiData + ))->intersectByKeys([ + 'email' => '', + 'firstname' => '', + 'lastname' => '', + 'address' => '', + 'address2' => '', + 'postcode' => '', + 'birth_date' => '', + 'city' => '', + 'country' => '', + 'opt_in' => '', + 'phone' => '' + ])->toArray(); + } else { + return parent::toArray(); + } + } +} diff --git a/app/Providers/CrmApiServiceProvider.php b/app/Providers/CrmApiServiceProvider.php new file mode 100644 index 0000000..0e2af07 --- /dev/null +++ b/app/Providers/CrmApiServiceProvider.php @@ -0,0 +1,22 @@ + 'users', 'hash' => false, ], + + 'customer' => [ + 'driver' => 'session', + 'provider' => 'customers', + ], ], /* @@ -71,6 +76,11 @@ return [ 'model' => App\Models\User::class, ], + 'customers' => [ + 'driver' => 'eloquent', + 'model' => App\Models\Customers::class, + ] + // 'users' => [ // 'driver' => 'database', // 'table' => 'users', diff --git a/config/crm.php b/config/crm.php new file mode 100644 index 0000000..590111c --- /dev/null +++ b/config/crm.php @@ -0,0 +1,8 @@ + env('CRM_ENDPOINT'), + 'CRM_API_TOKEN' => env('CRM_API_TOKEN'), + +]; diff --git a/database/migrations/2021_02_04_175136_create_customers_table.php b/database/migrations/2021_02_04_175136_create_customers_table.php new file mode 100644 index 0000000..930b27d --- /dev/null +++ b/database/migrations/2021_02_04_175136_create_customers_table.php @@ -0,0 +1,41 @@ +id(); + + $table->bigInteger('crm_id')->unsigned()->unique(); + + $table->string('email')->unique(); + $table->string('hashcode')->unique(); + $table->string('username')->unique(); + + $table->rememberToken(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('customers'); + } +} diff --git a/resources/views/front/canard/auth/register.blade.php b/resources/views/front/canard/auth/register.blade.php index 43a59b3..a82cb13 100644 --- a/resources/views/front/canard/auth/register.blade.php +++ b/resources/views/front/canard/auth/register.blade.php @@ -39,6 +39,14 @@ +
+
+ +
+
+ +
+
@@ -50,17 +58,44 @@
- +
- + +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
diff --git a/resources/views/front/canard/mails/password-reset.blade.php b/resources/views/front/canard/mails/password-reset.blade.php new file mode 100644 index 0000000..02416f7 --- /dev/null +++ b/resources/views/front/canard/mails/password-reset.blade.php @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Le Gaulois + + + + Les produits + + + + Côté cuisine + + + + La marque + + + + En ce moment + +
+ + Le Club Le Gaulois + +
+ MOT DE PASSE +
+

Bonjour,

+

Pour changer votre mot de passe, cliquez sur le lien suivant :

+

Cliquez ici

+
+

Gauloisement vôtre,
L’équipe Le Gaulois

+ +
+ + Le Club Le Gaulois + + + + Facebook + +
diff --git a/resources/views/front/canard/mails/register-ok.blade.php b/resources/views/front/canard/mails/register-ok.blade.php new file mode 100644 index 0000000..bbba89c --- /dev/null +++ b/resources/views/front/canard/mails/register-ok.blade.php @@ -0,0 +1,87 @@ + + + + Inscription au Club Le Gaulois + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Le Gaulois + + + + Les produits + + + + Côté cuisine + + + + La marque + + + + En ce moment + +
+ + Le Club Le Gaulois + +
+ Inscription - Le Gaulois +
+

Bonjour{{ $firstname !== null ? " " . $firstname : null }},

+

Vous venez de créer un compte sur le club des Gaulois : quelle bonne idée pour bénéficier du forum et de la Bourse aux échanges Départ’aimants et profitez des bons de réduction à imprimer !

+
+

Vous pouvez également enregistrer vos recettes favorites et les commenter et faire une liste de courses avec vos produits Le Gaulois préféré.

+
+

Pour confirmer votre inscription, rendez-vous à l'adresse suivante :
{{ route('activer', $customer->hashcode) }}
ou cliquez sur le lien ci-dessous.

+
+ + Activer mon compte - Le Gaulois + +
+

Gauloisement vôtre,
L’équipe Le Gaulois

+ +
+ + Le Club Le Gaulois + + + + Facebook + +
+ + diff --git a/resources/views/front/canard/partials/products-list.blade.php b/resources/views/front/canard/partials/products-list.blade.php index b299578..20aa61e 100644 --- a/resources/views/front/canard/partials/products-list.blade.php +++ b/resources/views/front/canard/partials/products-list.blade.php @@ -43,7 +43,7 @@ @foreach ($products as $product)
- {{ $product->name }} + {{ ucwords(strtolower($product->name)) }}
{{ $product->formattedPrice }}/{{ $product->sell_unit }}
diff --git a/resources/views/front/canard/product.blade.php b/resources/views/front/canard/product.blade.php index 24953fd..e0e9dec 100644 --- a/resources/views/front/canard/product.blade.php +++ b/resources/views/front/canard/product.blade.php @@ -13,7 +13,7 @@
-

{{ $product->name }}

+

{{ ucwords(strtolower($product->name)) }}

{!! $product->description !!}
diff --git a/routes/web.php b/routes/web.php index 84c1ca4..c4976d3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\IndexController; use App\Http\Controllers\BasketController; use App\Http\Controllers\ProductsController; +use App\Http\Controllers\CustomerController; // BO use App\Http\Controllers\Bo\DashboardController; use App\Http\Controllers\Bo\ContentController; @@ -81,7 +82,21 @@ Route::namespace('Auth') Route::get('/se-connecter', [LoginController::class, 'index'])->name('login')->middleware('guest'); Route::post('/login', [LoginController::class, 'login'])->name('login.post')->middleware('guest'); Route::get('/se-deconnecter', [LoginController::class, 'logout'])->name('logout')->middleware('auth'); - Route::get('/inscription', [RegisterController::class, 'index'])->name('register')->middleware('guest'); - Route::post('/register', [RegisterController::class, 'register'])->name('register.post')->middleware('guest'); + //Route::get('/inscription', [RegisterController::class, 'index'])->name('register')->middleware('guest'); + //Route::post('/register', [RegisterController::class, 'register'])->name('register.post')->middleware('guest'); + Route::get('/inscription', [CustomerController::class, 'registerForm'])->name('register')->middleware('guest'); + Route::post('/register', [CustomerController::class, 'register'])->name('register.post')->middleware('guest'); Route::get('/mot-de-passe-oublie', [ResetPasswordController::class, 'index'])->name('reset-password')->middleware('guest'); }); + +/* +Route::get('/inscription', 'CustomerController@registerForm')->name('form-inscription'); +Route::post('/inscription', 'CustomerController@register')->name('inscription'); +Route::get('/activer/{hashcode}', 'CustomerController@activate')->name('activer'); +Route::get('/connexion', 'CustomerController@authenticateForm')->name('form-connexion'); +Route::post('/connexion', 'CustomerController@authenticate')->name('connexion'); +Route::get('/deconnexion', 'CustomerController@logout')->name('deconnexion')->middleware('auth:customer'); +Route::post('/reinitialiser-mdp', 'CustomerController@passwordReset')->name('reinit-mdp'); +Route::get('/reinitialiser-mdp/{token}', 'CustomerController@viewChangePassword')->name('form-change-mdp'); +Route::post('/reinitialiser-mdp/{token}', 'CustomerController@changePassword')->name('change-mdp'); +*/