From b60f61ad1faeb799e12eee41cabead60d12ea3f7 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Tue, 4 Aug 2026 15:16:05 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20add=20missing=20fields=20?= =?UTF-8?q?when=20update=20local=20customer=20when=20exists=20in=20CRM=20#?= =?UTF-8?q?30=20#31?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Auth/CrmUserProvider.php | 4 +++- .../Controllers/Fo/Auth/LoginController.php | 6 +++++- .../Fo/Auth/RegisterController.php | 20 +++++++++---------- .../Fo/Auth/ResetPasswordController.php | 3 --- app/Http/Resources/CustomerCrmResource.php | 16 +++++++-------- app/Models/Customer.php | 20 +++++++++---------- 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/app/Auth/CrmUserProvider.php b/app/Auth/CrmUserProvider.php index a9caf44..eb7c3a7 100644 --- a/app/Auth/CrmUserProvider.php +++ b/app/Auth/CrmUserProvider.php @@ -129,7 +129,9 @@ class CrmUserProvider extends EloquentUserProvider implements UserProvider { /** @var \Illuminate\Database\Eloquent\Model $model */ $model = $this->usedModel::firstOrNew([ - 'email' => $crmCustomer->email + 'email' => $crmCustomer->email, + 'firstname' => $crmCustomer->firstname, + 'lastname' => $crmCustomer->lastname, ]); // @phpstan-ignore-next-line $model->hashcode = $crmCustomer->hashcode; diff --git a/app/Http/Controllers/Fo/Auth/LoginController.php b/app/Http/Controllers/Fo/Auth/LoginController.php index a8160c5..c00fe17 100644 --- a/app/Http/Controllers/Fo/Auth/LoginController.php +++ b/app/Http/Controllers/Fo/Auth/LoginController.php @@ -115,7 +115,11 @@ class LoginController extends Controller } /** @var \App\Models\Customer $customerModel */ - $customerModel = new Customer(Arr::only($crmCustomer->jsonSerialize(), ['email'])); + $customerModel = new Customer(Arr::only($crmCustomer->jsonSerialize(), [ + 'firstname', + 'lastname', + 'email', + ])); $customerModel->hashcode = $crmCustomer->hashcode; if (!$customerModel->saveOrFail()) { diff --git a/app/Http/Controllers/Fo/Auth/RegisterController.php b/app/Http/Controllers/Fo/Auth/RegisterController.php index 8ccaa6e..53d0c00 100644 --- a/app/Http/Controllers/Fo/Auth/RegisterController.php +++ b/app/Http/Controllers/Fo/Auth/RegisterController.php @@ -158,17 +158,17 @@ class RegisterController extends Controller return \array_intersect_key( $data, [ - 'firstname' => '', - 'lastname' => '', + 'firstname' => '', + 'lastname' => '', 'birth_date' => '', - 'address' => '', - 'postcode' => '', - 'country' => '', - 'city' => '', - 'phone' => '', - 'email' => '', - 'password' => '', - 'opt_in' => '', + 'address' => '', + 'postcode' => '', + 'country' => '', + 'city' => '', + 'phone' => '', + 'email' => '', + 'password' => '', + 'opt_in' => '', ] ); } diff --git a/app/Http/Controllers/Fo/Auth/ResetPasswordController.php b/app/Http/Controllers/Fo/Auth/ResetPasswordController.php index 18c7a0d..8e6f315 100644 --- a/app/Http/Controllers/Fo/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Fo/Auth/ResetPasswordController.php @@ -65,9 +65,6 @@ class ResetPasswordController extends Controller */ protected function resetPassword($customer, $password) { - /** @var \App\Models\Customer\Customer $user */ - /** @var string $password */ - /** @var \LDC\LDCCRM\CrmApiV4 */ $crm = app('crmAPI'); diff --git a/app/Http/Resources/CustomerCrmResource.php b/app/Http/Resources/CustomerCrmResource.php index c0ce426..7d539f0 100644 --- a/app/Http/Resources/CustomerCrmResource.php +++ b/app/Http/Resources/CustomerCrmResource.php @@ -31,16 +31,16 @@ class CustomerCrmResource extends JsonResource /** @var \LDC\LDCCRM\Models\Customer */ $crmCustomer = $this->customer->api_data; return [ - 'hashcode' => $this->customer->hashcode, + 'hashcode' => $this->customer->hashcode, 'firstname' => $crmCustomer->firstname, - 'lastname' => $crmCustomer->lastname, - 'opt_in' => $crmCustomer->opt_in, + 'lastname' => $crmCustomer->lastname, + 'opt_in' => $crmCustomer->opt_in, 'birthdate' => $crmCustomer->birth_date, - 'phone' => $crmCustomer->phone, - 'address' => $crmCustomer->address, - 'address2' => $crmCustomer->address2, - 'city' => $crmCustomer->city, - 'postcode' => $crmCustomer->postcode + 'phone' => $crmCustomer->phone, + 'address' => $crmCustomer->address, + 'address2' => $crmCustomer->address2, + 'city' => $crmCustomer->city, + 'postcode' => $crmCustomer->postcode ]; } } diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 90a7125..e50cff6 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -284,17 +284,17 @@ class Customer extends Authenticatable implements MustVerifyEmail, CanResetPassw parent::toArray(), (array)$this->apiData ))->intersectByKeys([ - 'email' => '', - 'firstname' => '', - 'lastname' => '', - 'address' => '', - 'address2' => '', - 'postcode' => '', + 'email' => '', + 'firstname' => '', + 'lastname' => '', + 'address' => '', + 'address2' => '', + 'postcode' => '', 'birth_date' => '', - 'city' => '', - 'country' => '', - 'opt_in' => '', - 'phone' => '' + 'city' => '', + 'country' => '', + 'opt_in' => '', + 'phone' => '', ])->toArray(); } else { return parent::toArray();