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-11 13:32:07 +10:00

57 lines
1.2 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
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;
}
}