1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 19:33:07 +01:00

Save customer name if empty on create

This commit is contained in:
FreeScout 2018-08-29 00:02:11 -07:00
parent 3691b3ca18
commit a94de0cb9e

View File

@ -660,13 +660,22 @@ class Customer extends Model
$email_obj = Email::where('email', $email)->first();
if ($email_obj) {
$customer = $email_obj->customer;
if (empty($customer->first_name) && !empty($data['first_name'])) {
$customer->first_name = $data['first_name'];
if (empty($customer->last_name) && !empty($data['last_name'])) {
$customer->last_name = $data['last_name'];
}
$customer->save();
}
} else {
$customer = new self();
$email_obj = new Email();
$email_obj->email = $email;
$customer->fill($data);
$customer->save();
}
$customer->fill($data);
$customer->save();
if (empty($email_obj->id) || !$email_obj->customer_id) {
$email_obj->customer()->associate($customer);