- Make all tests pass Client (V4),CRMV2,CRMV4 - Simplify client submodule path - Move App_url to .env.testing
60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\Customer;
|
|
use App\Models\CustomerLogin;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class UpdateCustomerLastConnection implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
/** @var \Illuminate\Support\Carbon */
|
|
protected $date = null;
|
|
|
|
/** @var \App\Models\Customer */
|
|
protected $customer = null;
|
|
|
|
/** @var \App\Models\CustomerLogin */
|
|
protected $customerLogin = null;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @param \App\Models\Customer $customer
|
|
* @param \App\Models\CustomerLogin $customerLogin
|
|
* @param \Illuminate\Support\Carbon $date
|
|
* @return void
|
|
*/
|
|
public function __construct(
|
|
Customer $customer,
|
|
CustomerLogin $customerLogin,
|
|
Carbon $date
|
|
) {
|
|
$this->date = $date;
|
|
$this->customer = $customer;
|
|
$this->customerLogin = $customerLogin;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
if ($this->customerLogin->last_connection < $this->date) {
|
|
$this->customerLogin->last_connection = $this->date;
|
|
$this->customer->logins()->save($this->customerLogin);
|
|
}
|
|
}
|
|
}
|