Passed
Push — feature/job-status-queued-tran... ( 148853 )
by Tristan
07:07
created

ProcessJobStatusTransitions::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
dl 0
loc 2
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Jobs;
4
5
use Jenssegers\Date\Date;
6
use App\Models\JobPoster;
7
use App\Models\Lookup\JobPosterStatus;
8
use Illuminate\Bus\Queueable;
9
use Illuminate\Contracts\Queue\ShouldQueue;
10
use Illuminate\Foundation\Bus\Dispatchable;
11
use Illuminate\Queue\InteractsWithQueue;
12
use Illuminate\Queue\SerializesModels;
13
use Illuminate\Support\Facades\Log;
14
15
class ProcessJobStatusTransitions implements ShouldQueue
16
{
17
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
18
19
    /**
20
     * Create a new job instance.
21
     *
22
     * @return void
23
     */
24
    public function __construct()
25
    {
26
        //
27
    }
28
29
    /**
30
     * Execute the job.
31
     *
32
     * @return void
33
     */
34
    public function handle()
35
    {
36
        $now = Date::now();
37
        $published = JobPosterStatus::where('key', 'published')->first();
38
        $completed = JobPosterStatus::where('key', 'completed')->first();
39
        $jobsReadyForClose = JobPoster::where('job_poster_status_id', $published->id)
40
            ->where('close_date_time', '<=', $now)->get();
41
        foreach ($jobsReadyForClose as $job) {
42
            $job->job_poster_status_id = $completed->id;
43
            $job->save();
44
        }
45
    }
46
}
47