2018-12-02 11:42:06 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2018-12-02 11:42:06 +01:00
|
|
|
|
|
|
|
namespace App\Jobs\Client;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Models\Client;
|
2019-01-25 11:47:23 +01:00
|
|
|
use App\Repositories\ClientContactRepository;
|
2018-12-02 11:42:06 +01:00
|
|
|
use App\Repositories\ClientRepository;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class StoreClient
|
|
|
|
{
|
|
|
|
use Dispatchable;
|
|
|
|
|
2019-05-10 08:08:33 +02:00
|
|
|
protected $data;
|
2018-12-02 11:42:06 +01:00
|
|
|
|
|
|
|
protected $client;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
2019-05-10 08:08:33 +02:00
|
|
|
public function __construct(array $data, Client $client)
|
2018-12-02 11:42:06 +01:00
|
|
|
{
|
2019-05-10 08:08:33 +02:00
|
|
|
$this->data = $data;
|
|
|
|
|
2018-12-02 11:42:06 +01:00
|
|
|
$this->client = $client;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2019-05-10 08:08:33 +02:00
|
|
|
public function handle(ClientRepository $client_repo, ClientContactRepository $client_contact_repo) : ?Client
|
|
|
|
|
|
|
|
$client = $client_repo->save($this->data, $this->client);
|
2019-01-25 11:47:23 +01:00
|
|
|
|
2019-05-10 08:08:33 +02:00
|
|
|
$contacts = $client_contact_repo->save($data['contacts']), $client);
|
2019-02-17 12:07:58 +01:00
|
|
|
|
|
|
|
return $client;
|
2018-12-02 11:42:06 +01:00
|
|
|
}
|
|
|
|
}
|