44 lines
No EOL
1,014 B
PHP
44 lines
No EOL
1,014 B
PHP
<?php
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
|
use App\Models\Lead;
|
|
use App\Models\Booking;
|
|
use App\Models\Customer;
|
|
|
|
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;
|
|
}
|
|
//by Lead ID
|
|
public function updateCustomerFromLead($id, $data){
|
|
|
|
$lead = Lead::findOrFail($id);
|
|
if(isset($data['customer']) && $lead->customer){
|
|
return $this->updateCustomer($lead->customer->id, $data['customer']);
|
|
}
|
|
}
|
|
//by Booking ID
|
|
public function updateCustomerFromBooking($id, $data){
|
|
|
|
$booking = Booking::findOrFail($id);
|
|
if(isset($data['customer']) && $booking->customer){
|
|
return $this->updateCustomer($booking->customer->id, $data['customer']);
|
|
}
|
|
}
|
|
|
|
|
|
} |