Blame view
app/Console/Commands/DispatchResumeLiftJobCommand.php
1.38 KB
8ec6b4403 task-132985 autor... |
1 2 3 |
<?php namespace App\Console\Commands; |
bae7fd15b task-132985 minor... |
4 |
use App\Jobs\LiftResumeJob; |
8ec6b4403 task-132985 autor... |
5 6 7 8 9 10 11 12 13 14 |
use App\Models\WorkerAutoliftOption; use Illuminate\Console\Command; class DispatchResumeLiftJobCommand extends Command { protected $signature ='resume:dispatch'; public function handle() { $now = now()->timezone('Europe/Moscow')->format('H:i'); |
7d97dde35 task-132985 minor... |
15 |
$workers = WorkerAutoliftOption::query() |
8ec6b4403 task-132985 autor... |
16 17 18 19 20 21 |
->where(function ($query) use ($now) { $query->where('times_per_day', 1) ->where('time_send_first', $now); }) ->orWhere(function ($query) use ($now) { $query->where('times_per_day', 2) |
7d97dde35 task-132985 minor... |
22 23 24 25 |
->where(function ($query) use ($now) { $query->where('time_send_first', $now) ->orWhere('time_send_second', $now); }); |
8ec6b4403 task-132985 autor... |
26 27 28 |
}) ->orWhere(function ($query) use ($now) { $query->where('times_per_day', 3) |
7d97dde35 task-132985 minor... |
29 30 31 32 33 |
->where(function ($query) use ($now) { $query->where('time_send_first', $now) ->orWhere('time_send_second', $now) ->orWhere('time_send_third', $now); }); |
8ec6b4403 task-132985 autor... |
34 35 |
}) ->get(); |
bae7fd15b task-132985 minor... |
36 |
LiftResumeJob::dispatch($workers->pluck('worker_id')->toArray()); |
8ec6b4403 task-132985 autor... |
37 38 39 40 |
return Command::SUCCESS; } } |