mein-sterntours/app/Repositories/CustomerRepository.php
2021-05-07 17:44:02 +02:00

48 lines
No EOL
1.1 KiB
PHP

<?php
namespace App\Repositories;
use App\Models\Customer;
use App\Models\Lead;
class CustomerRepository extends BaseRepository {
public function __construct(Customer $model)
{
$this->model = $model;
}
public function updateCustomer($id, $data)
{
$this->model = Customer::findOrFail($id);
$fill = [
'salutation_id' => $data['salutation_id'],
'name' => $data['name'],
'firstname' => $data['firstname'],
'street' => $data['street'],
'zip' => $data['zip'],
'city' => $data['city'],
'email' => $data['email'],
'phone' => $data['phone'],
'phonemobile' => $data['phonemobile'],
'country_id' => $data['country_id'],
];
$this->model->fill($fill);
$this->model->save();
return $this->model;
}
public function updateCustomerFromLead($id, $data){
$lead = Lead::findOrFail($id);
if(isset($data['customer']) && $lead->customer){
return $this->updateCustomer($lead->customer->id, $data['customer']);
}
}
}