1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-06 03:02:34 +01:00
invoiceninja/app/Jobs/Client/StoreClient.php
2019-05-10 16:08:33 +10:00

48 lines
922 B
PHP

<?php
namespace App\Jobs\Client;
use App\Models\Client;
use App\Repositories\ClientContactRepository;
use App\Repositories\ClientRepository;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class StoreClient
{
use Dispatchable;
protected $data;
protected $client;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(array $data, Client $client)
{
$this->data = $data;
$this->client = $client;
}
/**
* Execute the job.
*
* @return void
*/
public function handle(ClientRepository $client_repo, ClientContactRepository $client_contact_repo) : ?Client
$client = $client_repo->save($this->data, $this->client);
$contacts = $client_contact_repo->save($data['contacts']), $client);
return $client;
}
}