2018-12-02 21:42:06 +11:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Jobs\Client;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use App\Models\Client;
|
2019-01-25 21:47:23 +11:00
|
|
|
use App\Repositories\ClientContactRepository;
|
2018-12-02 21:42:06 +11:00
|
|
|
use App\Repositories\ClientRepository;
|
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
|
|
class StoreClient
|
|
|
|
|
{
|
|
|
|
|
use Dispatchable;
|
|
|
|
|
|
|
|
|
|
protected $request;
|
|
|
|
|
|
|
|
|
|
protected $client;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new job instance.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function __construct(Request $request, Client $client)
|
|
|
|
|
{
|
|
|
|
|
$this->request = $request;
|
|
|
|
|
$this->client = $client;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute the job.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2019-01-25 21:47:23 +11:00
|
|
|
public function handle(ClientRepository $clientRepo, ClientContactRepository $clientContactRepo) : ?Client
|
2018-12-02 21:42:06 +11:00
|
|
|
{
|
2019-01-25 21:47:23 +11:00
|
|
|
$client = $clientRepo->save($this->request, $this->client);
|
|
|
|
|
|
|
|
|
|
$contacts = $clientContactRepo->save($this->request->input('contacts'), $client);
|
2019-02-17 22:07:58 +11:00
|
|
|
|
|
|
|
|
return $client;
|
2018-12-02 21:42:06 +11:00
|
|
|
}
|
|
|
|
|
}
|