2019-11-20 06:41:49 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-11-20 06:41:49 +01:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Jobs\Client;
|
|
|
|
|
2019-12-29 07:28:57 +01:00
|
|
|
use App\Libraries\MultiDB;
|
2019-11-20 06:41:49 +01:00
|
|
|
use App\Models\Client;
|
2019-12-29 07:28:57 +01:00
|
|
|
use App\Models\Company;
|
2019-11-20 06:41:49 +01:00
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
|
|
|
|
class UpdateClientPaidToDate
|
|
|
|
{
|
|
|
|
use Dispatchable;
|
|
|
|
|
|
|
|
protected $amount;
|
|
|
|
|
|
|
|
protected $client;
|
|
|
|
|
2019-12-29 07:28:57 +01:00
|
|
|
private $company;
|
2019-11-20 06:41:49 +01:00
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
2019-12-29 07:28:57 +01:00
|
|
|
public function __construct(Client $client, $amount, Company $company)
|
2019-11-20 06:41:49 +01:00
|
|
|
{
|
|
|
|
$this->amount = $amount;
|
|
|
|
$this->client = $client;
|
2019-12-29 07:28:57 +01:00
|
|
|
$this->company = $company;
|
2019-11-20 06:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2019-12-30 22:59:12 +01:00
|
|
|
public function handle()
|
2019-11-20 06:41:49 +01:00
|
|
|
{
|
2019-12-29 07:28:57 +01:00
|
|
|
MultiDB::setDB($this->company->db);
|
2019-11-20 06:41:49 +01:00
|
|
|
|
|
|
|
$this->client->paid_to_date += $this->amount;
|
|
|
|
$this->client->save();
|
|
|
|
}
|
|
|
|
}
|