Completed
Push — feature/manager_view_app_profi... ( 5ff349...1f9820 )
by Tristan
06:53
created

JobPoster::job_applications()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * Created by Reliese Model.
5
 * Date: Thu, 12 Jul 2018 22:39:27 +0000.
6
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in file comment
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
7
8
namespace App\Models;
9
10
use App\Events\JobSaved;
11
use App\Models\JobApplication;
12
use Illuminate\Notifications\Notifiable;
13
use Jenssegers\Date\Date;
14
15
/**
16
 * Class JobPoster
17
 *
18
 * @property int $id
19
 * @property int $job_term_id
20
 * @property int $term_qty
21
 * @property \Jenssegers\Date\Date $open_date_time
22
 * @property \Jenssegers\Date\Date $close_date_time
23
 * @property \Jenssegers\Date\Date $start_date_time
24
 * @property int $department_id
25
 * @property int $province_id
26
 * @property int $salary_min
27
 * @property int $salary_max
28
 * @property int $noc
29
 * @property string $classification
30
 * @property int $security_clearance_id
31
 * @property int $language_requirement_id
32
 * @property boolean $remote_work_allowed
33
 * @property int $manager_id
34
 * @property boolean $published
35
 * @property \Jenssegers\Date\Date $created_at
36
 * @property \Jenssegers\Date\Date $updated_at
37
 *
38
 * @property int $submitted_applications_count
39
 *
40
 * @property \App\Models\Lookup\Department $department
41
 * @property \App\Models\Lookup\JobTerm $job_term
42
 * @property \App\Models\Lookup\LanguageRequirement $language_requirement
43
 * @property \App\Models\Manager $manager
44
 * @property \App\Models\Lookup\Province $province
45
 * @property \App\Models\Lookup\SecurityClearance $security_clearance
46
 * @property \Illuminate\Database\Eloquent\Collection $criteria
47
 * @property \Illuminate\Database\Eloquent\Collection $job_applications
48
 * @property \Illuminate\Database\Eloquent\Collection $job_poster_key_tasks
49
 * @property \Illuminate\Database\Eloquent\Collection $job_poster_questions
50
 * @property \Illuminate\Database\Eloquent\Collection $job_poster_translations
51
 * @property \Illuminate\Database\Eloquent\Collection $submitted_applications
52
 *
53
 * Localized Properties:
54
 * @property string $city
55
 * @property string $title
56
 * @property string $impact
57
 * @property string $branch
58
 * @property string $division
59
 * @property string $education
60
 *
61
 * Methods
62
 * @method boolean isOpen()
0 ignored issues
show
Coding Style introduced by
Tag value indented incorrectly; expected 3 spaces but found 1
Loading history...
63
 * @method string timeRemaining()
0 ignored issues
show
Coding Style introduced by
Tag value indented incorrectly; expected 3 spaces but found 1
Loading history...
64
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
65
class JobPoster extends BaseModel {
0 ignored issues
show
Coding Style introduced by
Opening brace of a class must be on the line after the definition
Loading history...
66
67
    use \Dimsav\Translatable\Translatable;
0 ignored issues
show
introduced by
The trait Dimsav\Translatable\Translatable requires some properties which are not provided by App\Models\JobPoster: $translations, $useTranslationFallback, $translationModel, $localeKey, $translationForeignKey
Loading history...
68
    use Notifiable;
0 ignored issues
show
introduced by
The trait Illuminate\Notifications\Notifiable requires some properties which are not provided by App\Models\JobPoster: $email, $phone_number
Loading history...
69
70
    public $translatedAttributes = ['city', 'title', 'impact', 'branch', 'division', 'education'];
71
    protected $casts = [
72
        'job_term_id' => 'int',
73
        'department_id' => 'int',
74
        'province_id' => 'int',
75
        'salary_min' => 'int',
76
        'salary_max' => 'int',
77
        'noc' => 'int',
78
        'security_clearance_id' => 'int',
79
        'language_requirement_id' => 'int',
80
        'remote_work_allowed' => 'boolean',
81
        'manager_id' => 'int',
82
        'published' => 'boolean'
83
    ];
84
    protected $dates = [
85
        'open_date_time',
86
        'close_date_time',
87
        'start_date_time'
88
    ];
89
    protected $fillable = [
90
        'job_term_id',
91
        'term_qty',
92
        'open_date_time',
93
        'close_date_time',
94
        'start_date_time',
95
        'department_id',
96
        'province_id',
97
        'salary_min',
98
        'salary_max',
99
        'noc',
100
        'classification',
101
        'security_clearance_id',
102
        'language_requirement_id',
103
        'remote_work_allowed',
104
        'published'
105
    ];
106
    protected $withCount = ['submitted_applications'];
107
108
    protected $dispatchesEvents = [
109
        'saved' => JobSaved::class,
110
    ];
111
112
    public function department() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function department()
Loading history...
113
        return $this->belongsTo(\App\Models\Lookup\Department::class);
114
    }
115
116
    public function job_term() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function job_term()
Loading history...
Coding Style introduced by
Public method name "JobPoster::job_term" is not in camel caps format
Loading history...
117
        return $this->belongsTo(\App\Models\Lookup\JobTerm::class);
118
    }
119
120
    public function language_requirement() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function language_requirement()
Loading history...
Coding Style introduced by
Public method name "JobPoster::language_requirement" is not in camel caps format
Loading history...
121
        return $this->belongsTo(\App\Models\Lookup\LanguageRequirement::class);
122
    }
123
124
    public function manager() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function manager()
Loading history...
125
        return $this->belongsTo(\App\Models\Manager::class);
126
    }
127
128
    public function province() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function province()
Loading history...
129
        return $this->belongsTo(\App\Models\Lookup\Province::class);
130
    }
131
132
    public function security_clearance() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function security_clearance()
Loading history...
Coding Style introduced by
Public method name "JobPoster::security_clearance" is not in camel caps format
Loading history...
133
        return $this->belongsTo(\App\Models\Lookup\SecurityClearance::class);
134
    }
135
136
    public function criteria() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function criteria()
Loading history...
137
        return $this->hasMany(\App\Models\Criteria::class);
138
    }
139
140
    public function job_applications() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function job_applications()
Loading history...
Coding Style introduced by
Public method name "JobPoster::job_applications" is not in camel caps format
Loading history...
141
        return $this->hasMany(\App\Models\JobApplication::class);
142
    }
143
144
    public function job_poster_key_tasks() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function job_poster_key_tasks()
Loading history...
Coding Style introduced by
Public method name "JobPoster::job_poster_key_tasks" is not in camel caps format
Loading history...
145
        return $this->hasMany(\App\Models\JobPosterKeyTask::class);
146
    }
147
148
    public function job_poster_questions() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function job_poster_questions()
Loading history...
Coding Style introduced by
Public method name "JobPoster::job_poster_questions" is not in camel caps format
Loading history...
149
        return $this->hasMany(\App\Models\JobPosterQuestion::class);
150
    }
151
152
    public function job_poster_translations() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function job_poster_translations()
Loading history...
Coding Style introduced by
Public method name "JobPoster::job_poster_translations" is not in camel caps format
Loading history...
153
        return $this->hasMany(\App\Models\JobPosterTranslation::class);
154
    }
155
156
    // Artificial Relations
157
158
    public function submitted_applications() {
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a function comment
Loading history...
Coding Style introduced by
Public method name "JobPoster::submitted_applications" is not in camel caps format
Loading history...
159
        return $this->hasMany(\App\Models\JobApplication::class)->whereHas('application_status', function ($query) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
160
            $query->where('name', '!=', 'draft');
161
        });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
162
    }
163
164
    // Accessors
165
166
    // Methods
167
168
    public function isOpen() {
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a function comment
Loading history...
169
        return $this->published
170
            && $this->open_date_time->isPast()
171
            && $this->close_date_time->isFuture();
172
    }
173
174
    public function timeRemaining() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function timeRemaining()
Loading history...
175
        if ($this->close_date_time->isFuture()) {
176
            return $this->close_date_time->diffForHumans(null, true);
177
        } else {
178
            return $this->close_date_time->diffForHumans(Date::now());
179
        }
180
    }
181
}
182