2018-11-22 12:12:41 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
2018-11-27 07:59:16 +01:00
|
|
|
use App\Models\Client;
|
2018-11-22 12:12:41 +01:00
|
|
|
use App\Repositories\ClientContactRepository;
|
2018-11-27 07:59:16 +01:00
|
|
|
use Illuminate\Http\Request;
|
2018-11-22 12:12:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class ClientRepository extends BaseRepository
|
|
|
|
{
|
2018-11-27 07:59:16 +01:00
|
|
|
protected $clientContactRepo;
|
2018-11-22 12:12:41 +01:00
|
|
|
|
2018-11-27 07:59:16 +01:00
|
|
|
public function __construct(ClientContactRepository $clientContactRepo)
|
2018-11-22 12:12:41 +01:00
|
|
|
{
|
2018-11-27 07:59:16 +01:00
|
|
|
$this->clientContactRepo = $clientContactRepo;
|
2018-11-22 12:12:41 +01:00
|
|
|
}
|
|
|
|
|
2018-11-27 07:59:16 +01:00
|
|
|
public function save(Request $request, Client $client) : ?Client
|
2018-11-22 12:12:41 +01:00
|
|
|
{
|
2018-11-27 07:59:16 +01:00
|
|
|
$client->fill($request->input());
|
|
|
|
$client->save();
|
2018-11-22 12:12:41 +01:00
|
|
|
|
2018-11-27 07:59:16 +01:00
|
|
|
$this->clientContactRepo->save($request->input('contacts'), $client);
|
|
|
|
|
|
|
|
return $client;
|
2018-11-22 12:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|