Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| 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 |
n/a |
0 / 0 |
1 | |||||
| handle | n/a |
0 / 0 |
n/a |
0 / 0 |
2 | |||||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Jobs; |
| 4 | |
| 5 | use App\Models\Customer; |
| 6 | use App\Models\CustomerLogin; |
| 7 | use Illuminate\Bus\Queueable; |
| 8 | use Illuminate\Contracts\Queue\ShouldQueue; |
| 9 | use Illuminate\Foundation\Bus\Dispatchable; |
| 10 | use Illuminate\Queue\InteractsWithQueue; |
| 11 | use Illuminate\Queue\SerializesModels; |
| 12 | use Illuminate\Support\Carbon; |
| 13 | |
| 14 | /** |
| 15 | * @codeCoverageIgnore |
| 16 | */ |
| 17 | class 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 | } |