1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Jobs/Client/UpdateClient.php

57 lines
1.2 KiB
PHP
Raw Normal View History

<?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
*/
namespace App\Jobs\Client;
use App\Models\Client;
2019-01-26 10:34:38 +01:00
use App\Repositories\ClientContactRepository;
use App\Repositories\ClientRepository;
2019-01-26 10:34:38 +01:00
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;
2019-01-26 10:34:38 +01:00
use Illuminate\Support\Facades\Log;
class UpdateClient
{
use Dispatchable;
2019-05-10 08:08:33 +02:00
protected $data;
protected $client;
/**
* Create a new job instance.
*
* @return void
*/
2019-05-10 08:08:33 +02:00
public function __construct(array $data, Client $client)
{
2019-05-10 08:08:33 +02:00
$this->data = $data;
$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
{
2019-05-10 08:08:33 +02:00
$client = $client_repo->save($this->data, $this->client);
2019-01-26 10:34:38 +01:00
2019-05-10 08:08:33 +02:00
$contacts = $client_contact_repo->save($data['contacts']), $client);
2019-01-26 10:34:38 +01:00
2019-01-26 22:24:16 +01:00
return $client->fresh();
}
}