Passed
Push — feature/temp_view_app_2 ( 1c0007...cc9029 )
by Tristan
16:31 queued 08:09
created

JobPoster   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 13
eloc 53
dl 0
loc 103
ccs 0
cts 29
cp 0
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A job_poster_translations() 0 2 1
A province() 0 2 1
A job_applications() 0 2 1
A language_requirement() 0 2 1
A job_term() 0 2 1
A department() 0 2 1
A getDaysRemainingAttribute() 0 4 1
A criteria() 0 2 1
A manager() 0 2 1
A submitted_applications() 0 3 1
A job_poster_questions() 0 2 1
A security_clearance() 0 2 1
A job_poster_key_tasks() 0 2 1
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 int $manager_id
33
 * @property boolean $published
34
 * @property \Jenssegers\Date\Date $created_at
35
 * @property \Jenssegers\Date\Date $updated_at
36
 *
37
 * @property int $submitted_applications_count
38
 * @property int $days_remaining
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
 */
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...
61
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...
62
63
    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...
64
    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...
65
66
    public $translatedAttributes = ['city', 'title', 'impact', 'branch', 'division', 'education'];
67
    protected $casts = [
68
        'job_term_id' => 'int',
69
        'department_id' => 'int',
70
        'province_id' => 'int',
71
        'salary_min' => 'int',
72
        'salary_max' => 'int',
73
        'noc' => 'int',
74
        'security_clearance_id' => 'int',
75
        'language_requirement_id' => 'int',
76
        'manager_id' => 'int',
77
        'published' => 'boolean'
78
    ];
79
    protected $dates = [
80
        'open_date_time',
81
        'close_date_time',
82
        'start_date_time'
83
    ];
84
    protected $fillable = [
85
        'job_term_id',
86
        'term_qty',
87
        'open_date_time',
88
        'close_date_time',
89
        'start_date_time',
90
        'department_id',
91
        'province_id',
92
        'salary_min',
93
        'salary_max',
94
        'noc',
95
        'classification',
96
        'security_clearance_id',
97
        'language_requirement_id',
98
        'published'
99
    ];
100
    protected $withCount = ['submitted_applications'];
101
102
    protected $dispatchesEvents = [
103
        'saved' => JobSaved::class,
104
    ];
105
106
    public function department() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function department()
Loading history...
107
        return $this->belongsTo(\App\Models\Lookup\Department::class);
108
    }
109
110
    public function job_term() {
0 ignored issues
show
Coding Style introduced by
Public method name "JobPoster::job_term" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function job_term()
Loading history...
111
        return $this->belongsTo(\App\Models\Lookup\JobTerm::class);
112
    }
113
114
    public function language_requirement() {
0 ignored issues
show
Coding Style introduced by
Public method name "JobPoster::language_requirement" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function language_requirement()
Loading history...
115
        return $this->belongsTo(\App\Models\Lookup\LanguageRequirement::class);
116
    }
117
118
    public function manager() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function manager()
Loading history...
119
        return $this->belongsTo(\App\Models\Manager::class);
120
    }
121
122
    public function province() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function province()
Loading history...
123
        return $this->belongsTo(\App\Models\Lookup\Province::class);
124
    }
125
126
    public function security_clearance() {
0 ignored issues
show
Coding Style introduced by
Public method name "JobPoster::security_clearance" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function security_clearance()
Loading history...
127
        return $this->belongsTo(\App\Models\Lookup\SecurityClearance::class);
128
    }
129
130
    public function criteria() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function criteria()
Loading history...
131
        return $this->hasMany(\App\Models\Criteria::class);
132
    }
133
134
    public function job_applications() {
0 ignored issues
show
Coding Style introduced by
Public method name "JobPoster::job_applications" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function job_applications()
Loading history...
135
        return $this->hasMany(\App\Models\JobApplication::class);
136
    }
137
138
    public function job_poster_key_tasks() {
0 ignored issues
show
Coding Style introduced by
Public method name "JobPoster::job_poster_key_tasks" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function job_poster_key_tasks()
Loading history...
139
        return $this->hasMany(\App\Models\JobPosterKeyTask::class);
140
    }
141
142
    public function job_poster_questions() {
0 ignored issues
show
Coding Style introduced by
Public method name "JobPoster::job_poster_questions" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function job_poster_questions()
Loading history...
143
        return $this->hasMany(\App\Models\JobPosterQuestion::class);
144
    }
145
146
    public function job_poster_translations() {
0 ignored issues
show
Coding Style introduced by
Public method name "JobPoster::job_poster_translations" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function job_poster_translations()
Loading history...
147
        return $this->hasMany(\App\Models\JobPosterTranslation::class);
148
    }
149
150
    // Artificial Relations
151
152
    public function submitted_applications() {
0 ignored issues
show
Coding Style introduced by
Public method name "JobPoster::submitted_applications" is not in camel caps format
Loading history...
Coding Style introduced by
You must use "/**" style comments for a function comment
Loading history...
153
        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...
154
            $query->where('name', '!=', 'draft');
155
        });
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...
156
    }
157
158
    // Accessors
159
160
    public function getDaysRemainingAttribute() {
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a function comment
Loading history...
161
        $days_remaining = $this->close_date_time->diffInDays(Date::now());
162
        debugbar()->info($days_remaining);
163
        return $days_remaining;
164
    }
165
166
}
167