mein-sterntours/app/Repositories/CustomerRepository.php
2021-05-19 18:04:31 +02:00

34 lines
No EOL
687 B
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);
$this->model->fill($data);
$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']);
}
}
}