Merge branch 'create-customer' into 'develop'

fix: 🐛 add missing fields when creating local customer when exists in CRM #30

See merge request ldc-web/projets/jeusselin!20
This commit is contained in:
Noix 2026-09-25 10:43:57 +00:00
commit 968ee32e8d
6 changed files with 36 additions and 33 deletions

View file

@ -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;

View file

@ -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()) {

View file

@ -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' => '',
]
);
}

View file

@ -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');

View file

@ -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
];
}
}

View file

@ -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();