Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
UpdateCustomerLastConnection
n/a
0 / 0
n/a
0 / 0
3
n/a
0 / 0
 __construct
n/a
0 / 0
1
n/a
0 / 0
 handle
n/a
0 / 0
2
n/a
0 / 0
1<?php
2
3namespace App\Jobs;
4
5use App\Models\Customer;
6use App\Models\CustomerLogin;
7use Illuminate\Bus\Queueable;
8use Illuminate\Contracts\Queue\ShouldQueue;
9use Illuminate\Foundation\Bus\Dispatchable;
10use Illuminate\Queue\InteractsWithQueue;
11use Illuminate\Queue\SerializesModels;
12use Illuminate\Support\Carbon;
13
14/**
15 * @codeCoverageIgnore
16 */
17class UpdateCustomerLastConnection implements ShouldQueue
18{
19    use Dispatchable;
20    use InteractsWithQueue;
21    use Queueable;
22    use SerializesModels;
23
24    /** @var \Illuminate\Support\Carbon */
25    protected $date = null;
26
27    /** @var \App\Models\Customer */
28    protected $customer = null;
29
30    /** @var \App\Models\CustomerLogin */
31    protected $customerLogin = null;
32
33    /**
34     * Create a new job instance.
35     *
36     * @param Customer      $customer
37     * @param CustomerLogin $customerLogin
38     * @param Carbon        $date
39     * @return void
40     */
41    public function __construct(
42        Customer $customer,
43        CustomerLogin $customerLogin,
44        Carbon $date
45    ) {
46        $this->date          = $date;
47        $this->customer      = $customer;
48        $this->customerLogin = $customerLogin;
49    }
50
51    /**
52     * Execute the job.
53     *
54     * @return void
55     */
56    public function handle()
57    {
58        if ($this->customerLogin->last_connection < $this->date) {
59            $this->customerLogin->last_connection = $this->date;
60            $this->customer->logins()->save($this->customerLogin);
61        }
62    }
63}