Completed
Pull Request — dev (#369)
by Tristan
05:55
created

JobPoster::getDaysRemainingAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 4
ccs 0
cts 4
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 Illuminate\Notifications\Notifiable;
12
use Jenssegers\Date\Date;
13
14
/**
15
 * Class JobPoster
16
 *
17
 * @property int $id
18
 * @property int $job_term_id
19
 * @property int $term_qty
20
 * @property \Jenssegers\Date\Date $open_date_time
21
 * @property \Jenssegers\Date\Date $close_date_time
22
 * @property \Jenssegers\Date\Date $start_date_time
23
 * @property int $department_id
24
 * @property int $province_id
25
 * @property int $salary_min
26
 * @property int $salary_max
27
 * @property int $noc
28
 * @property string $classification
29
 * @property int $security_clearance_id
30
 * @property int $language_requirement_id
31
 * @property int $manager_id
32
 * @property boolean $published
33
 * @property \Jenssegers\Date\Date $created_at
34
 * @property \Jenssegers\Date\Date $updated_at
35
 *
36
 * @property \App\Models\Lookup\Department $department
37
 * @property \App\Models\Lookup\JobTerm $job_term
38
 * @property \App\Models\Lookup\LanguageRequirement $language_requirement
39
 * @property \App\Models\Manager $manager
40
 * @property \App\Models\Lookup\Province $province
41
 * @property \App\Models\Lookup\SecurityClearance $security_clearance
42
 * @property \Illuminate\Database\Eloquent\Collection $criteria
43
 * @property \Illuminate\Database\Eloquent\Collection $job_applications
44
 * @property \Illuminate\Database\Eloquent\Collection $job_poster_key_tasks
45
 * @property \Illuminate\Database\Eloquent\Collection $job_poster_questions
46
 * @property \Illuminate\Database\Eloquent\Collection $job_poster_translations
47
 *
48
 * Localized Properties:
49
 * @property string $city
50
 * @property string $title
51
 * @property string $impact
52
 * @property string $branch
53
 * @property string $division
54
 * @property string $education
55
 */
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...
56
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...
57
58
    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...
59
    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...
60
61
    public $translatedAttributes = ['city', 'title', 'impact', 'branch', 'division', 'education'];
62
    protected $casts = [
63
        'job_term_id' => 'int',
64
        'department_id' => 'int',
65
        'province_id' => 'int',
66
        'salary_min' => 'int',
67
        'salary_max' => 'int',
68
        'noc' => 'int',
69
        'security_clearance_id' => 'int',
70
        'language_requirement_id' => 'int',
71
        'manager_id' => 'int',
72
        'published' => 'boolean'
73
    ];
74
    protected $dates = [
75
        'open_date_time',
76
        'close_date_time',
77
        'start_date_time'
78
    ];
79
    protected $fillable = [
80
        'job_term_id',
81
        'term_qty',
82
        'open_date_time',
83
        'close_date_time',
84
        'start_date_time',
85
        'department_id',
86
        'province_id',
87
        'salary_min',
88
        'salary_max',
89
        'noc',
90
        'classification',
91
        'security_clearance_id',
92
        'language_requirement_id',
93
        'published'
94
    ];
95
96
    protected $dispatchesEvents = [
97
        'saved' => JobSaved::class,
98
    ];
99
100
    public function department() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function department()
Loading history...
101
        return $this->belongsTo(\App\Models\Lookup\Department::class);
102
    }
103
104
    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...
105
        return $this->belongsTo(\App\Models\Lookup\JobTerm::class);
106
    }
107
108
    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...
109
        return $this->belongsTo(\App\Models\Lookup\LanguageRequirement::class);
110
    }
111
112
    public function manager() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function manager()
Loading history...
113
        return $this->belongsTo(\App\Models\Manager::class);
114
    }
115
116
    public function province() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function province()
Loading history...
117
        return $this->belongsTo(\App\Models\Lookup\Province::class);
118
    }
119
120
    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...
121
        return $this->belongsTo(\App\Models\Lookup\SecurityClearance::class);
122
    }
123
124
    public function criteria() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function criteria()
Loading history...
125
        return $this->hasMany(\App\Models\Criteria::class);
126
    }
127
128
    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...
129
        return $this->hasMany(\App\Models\JobApplication::class);
130
    }
131
132
    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...
133
        return $this->hasMany(\App\Models\JobPosterKeyTask::class);
134
    }
135
136
    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...
137
        return $this->hasMany(\App\Models\JobPosterQuestion::class);
138
    }
139
140
    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...
141
        return $this->hasMany(\App\Models\JobPosterTranslation::class);
142
    }
143
    
144
    //Accessors
145
    
146
    public function getApplicantCountAttribute() {
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a function comment
Loading history...
147
        $applicant_count = $this->job_applications->whereNotIn('application_status.name', 'draft')->count();
148
        debugbar()->info($applicant_count);
149
        return $applicant_count;
150
    }
151
    
152
    public function getDaysRemainingAttribute() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getDaysRemainingAttribute()
Loading history...
153
        $days_remaining = $this->close_date_time->diffInDays(Date::now());
154
        debugbar()->info($days_remaining);
155
        return $days_remaining;
156
    }
157
158
}
159