@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @property \App\Models\User $user |
22 | 22 | */ |
23 | -class ProfilePic extends BaseModel { |
|
23 | +class ProfilePic extends BaseModel{ |
|
24 | 24 | |
25 | 25 | protected $casts = [ |
26 | 26 | 'user_id' => 'int', |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | 'image' |
32 | 32 | ]; |
33 | 33 | |
34 | - public function user() { |
|
35 | - return $this->belongsTo(\App\Models\User::class); |
|
34 | + public function user(){ |
|
35 | + return $this->belongsTo (\App\Models\User::class); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Jenssegers\Date\Date; |
10 | 10 | use DateTime; |
11 | 11 | |
12 | -abstract class BaseModel extends Eloquent { |
|
12 | +abstract class BaseModel extends Eloquent{ |
|
13 | 13 | //Override date functions to return Jenssegers Data instead of Carbon |
14 | 14 | |
15 | 15 | /** |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | */ |
31 | 31 | protected function asDateTime($value) |
32 | 32 | { |
33 | - $timezone = Config::get('app.timezone'); |
|
33 | + $timezone = Config::get ('app.timezone'); |
|
34 | 34 | |
35 | 35 | // If this value is already a Carbon instance, we shall just return it as is. |
36 | 36 | // This prevents us having to re-instantiate a Carbon instance when we know |
37 | 37 | // it already is one, which wouldn't be fulfilled by the DateTime check. |
38 | 38 | if ($value instanceof Carbon) { |
39 | - return Date::parse($value, $timezone); |
|
39 | + return Date::parse ($value, $timezone); |
|
40 | 40 | } |
41 | 41 | if ($value instanceof Date) { |
42 | 42 | return $value; |
@@ -45,35 +45,35 @@ discard block |
||
45 | 45 | // these checks since they will be a waste of time, and hinder performance |
46 | 46 | // when checking the field. We will just return the DateTime right away. |
47 | 47 | if ($value instanceof DateTimeInterface) { |
48 | - return new Date( |
|
48 | + return new Date ( |
|
49 | 49 | //$value->format('Y-m-d H:i:s.u'), $value->getTimeZone() |
50 | - $value->format('Y-m-d H:i:s.u'), $timezone |
|
50 | + $value->format ('Y-m-d H:i:s.u'), $timezone |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | // If this value is an integer, we will assume it is a UNIX timestamp's value |
54 | 54 | // and format a Carbon object from this timestamp. This allows flexibility |
55 | 55 | // when defining your date fields as they might be UNIX timestamps here. |
56 | - if (is_numeric($value)) { |
|
57 | - return Date::createFromTimestamp($value, $timezone); |
|
56 | + if (is_numeric ($value)) { |
|
57 | + return Date::createFromTimestamp ($value, $timezone); |
|
58 | 58 | } |
59 | 59 | // If the value is in simply year, month, day format, we will instantiate the |
60 | 60 | // Carbon instances from that format. Again, this provides for simple date |
61 | 61 | // fields on the database, while still supporting Carbonized conversion. |
62 | - if (preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value)) { |
|
63 | - return Date::createFromFormat('Y-m-d', $value, $timezone)->startOfDay(); |
|
62 | + if (preg_match ('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value)) { |
|
63 | + return Date::createFromFormat ('Y-m-d', $value, $timezone)->startOfDay (); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // If the date follows the api configured date format, use that. |
67 | - $apiFormat = Config::get('app.api_datetime_format'); |
|
68 | - $date = DateTime::createFromFormat($apiFormat, $value); |
|
69 | - if ($date && $date->format($apiFormat) == $value) { |
|
67 | + $apiFormat = Config::get ('app.api_datetime_format'); |
|
68 | + $date = DateTime::createFromFormat ($apiFormat, $value); |
|
69 | + if ($date && $date->format ($apiFormat) == $value) { |
|
70 | 70 | return $date; |
71 | 71 | } |
72 | 72 | |
73 | 73 | // Finally, we will just assume this date is in the format used by default on |
74 | 74 | // the database connection and use that format to create the Carbon object |
75 | 75 | // that is returned back out to the developers after we convert it here. |
76 | - return Date::createFromFormat($this->getDateFormat(), $value, $timezone); |
|
76 | + return Date::createFromFormat ($this->getDateFormat (), $value, $timezone); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -84,6 +84,6 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function serializeDate(DateTimeInterface $date) |
86 | 86 | { |
87 | - return $date->format(Config::get('app.api_datetime_format')); |
|
87 | + return $date->format (Config::get ('app.api_datetime_format')); |
|
88 | 88 | } |
89 | 89 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @property \Illuminate\Database\Eloquent\Collection $skill_declarations |
47 | 47 | * @property \App\Models\ApplicationReview $application_review |
48 | 48 | */ |
49 | -class JobApplication extends BaseModel { |
|
49 | +class JobApplication extends BaseModel{ |
|
50 | 50 | |
51 | 51 | use Notifiable; |
52 | 52 | |
@@ -85,52 +85,52 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected $appends = ['meets_essential_criteria']; |
87 | 87 | |
88 | - protected function createApplicantSnapshot($applicant_id) { |
|
89 | - $applicant = Applicant::where('id', $applicant_id)->firstOrFail(); |
|
88 | + protected function createApplicantSnapshot($applicant_id){ |
|
89 | + $applicant = Applicant::where ('id', $applicant_id)->firstOrFail (); |
|
90 | 90 | |
91 | - $snapshot = $applicant->replicate(); |
|
91 | + $snapshot = $applicant->replicate (); |
|
92 | 92 | |
93 | 93 | } |
94 | 94 | |
95 | - public function applicant() { |
|
96 | - return $this->belongsTo(\App\Models\Applicant::class); |
|
95 | + public function applicant(){ |
|
96 | + return $this->belongsTo (\App\Models\Applicant::class); |
|
97 | 97 | } |
98 | 98 | |
99 | - public function applicant_snapshot() { |
|
100 | - return $this->belongsTo(\App\Models\Applicant::class, 'applicant_snapshot_id'); |
|
99 | + public function applicant_snapshot(){ |
|
100 | + return $this->belongsTo (\App\Models\Applicant::class, 'applicant_snapshot_id'); |
|
101 | 101 | } |
102 | 102 | |
103 | - public function application_status() { |
|
104 | - return $this->belongsTo(\App\Models\Lookup\ApplicationStatus::class); |
|
103 | + public function application_status(){ |
|
104 | + return $this->belongsTo (\App\Models\Lookup\ApplicationStatus::class); |
|
105 | 105 | } |
106 | 106 | |
107 | - public function citizenship_declaration() { |
|
108 | - return $this->belongsTo(\App\Models\Lookup\CitizenshipDeclaration::class); |
|
107 | + public function citizenship_declaration(){ |
|
108 | + return $this->belongsTo (\App\Models\Lookup\CitizenshipDeclaration::class); |
|
109 | 109 | } |
110 | 110 | |
111 | - public function veteran_status() { |
|
112 | - return $this->belongsTo(\App\Models\Lookup\VeteranStatus::class); |
|
111 | + public function veteran_status(){ |
|
112 | + return $this->belongsTo (\App\Models\Lookup\VeteranStatus::class); |
|
113 | 113 | } |
114 | 114 | |
115 | - public function preferred_language() { |
|
116 | - return $this->belongsTo(\App\Models\Lookup\PreferredLanguage::class); |
|
115 | + public function preferred_language(){ |
|
116 | + return $this->belongsTo (\App\Models\Lookup\PreferredLanguage::class); |
|
117 | 117 | } |
118 | 118 | |
119 | - public function job_poster() { |
|
120 | - return $this->belongsTo(\App\Models\JobPoster::class); |
|
119 | + public function job_poster(){ |
|
120 | + return $this->belongsTo (\App\Models\JobPoster::class); |
|
121 | 121 | } |
122 | 122 | |
123 | - public function job_application_answers() { |
|
124 | - return $this->hasMany(\App\Models\JobApplicationAnswer::class); |
|
123 | + public function job_application_answers(){ |
|
124 | + return $this->hasMany (\App\Models\JobApplicationAnswer::class); |
|
125 | 125 | } |
126 | 126 | |
127 | - public function skill_declarations() { |
|
128 | - return $this->applicant->skill_declarations() |
|
129 | - ->whereIn('skill_id', $this->job_poster->criteria->pluck('skill_id')); |
|
127 | + public function skill_declarations(){ |
|
128 | + return $this->applicant->skill_declarations () |
|
129 | + ->whereIn ('skill_id', $this->job_poster->criteria->pluck ('skill_id')); |
|
130 | 130 | } |
131 | 131 | |
132 | - public function application_review() { |
|
133 | - return $this->hasOne(ApplicationReview::class); |
|
132 | + public function application_review(){ |
|
133 | + return $this->hasOne (ApplicationReview::class); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -146,41 +146,41 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string $status 'complete', 'incomplete' or 'error' |
148 | 148 | */ |
149 | - public function getSectionStatus(string $section) { |
|
149 | + public function getSectionStatus(string $section){ |
|
150 | 150 | //TODO: determine whether sections are complete or invalid |
151 | - $validator = new ApplicationValidator(); |
|
151 | + $validator = new ApplicationValidator (); |
|
152 | 152 | $status = 'incomplete'; |
153 | - switch($section) { |
|
153 | + switch ($section) { |
|
154 | 154 | case 'basics': |
155 | - if ($validator->basicsComplete($this)) { |
|
155 | + if ($validator->basicsComplete ($this)) { |
|
156 | 156 | $status = 'complete'; |
157 | 157 | } |
158 | 158 | break; |
159 | 159 | case 'experience': |
160 | - if ($validator->experienceComplete($this)) { |
|
160 | + if ($validator->experienceComplete ($this)) { |
|
161 | 161 | $status = 'complete'; |
162 | 162 | } |
163 | 163 | break; |
164 | 164 | case 'essential_skills': |
165 | - if ($validator->essentialSkillsComplete($this)) { |
|
165 | + if ($validator->essentialSkillsComplete ($this)) { |
|
166 | 166 | $status = 'complete'; |
167 | 167 | } |
168 | 168 | break; |
169 | 169 | case 'asset_skills': |
170 | - if ($validator->assetSkillsComplete($this)) { |
|
170 | + if ($validator->assetSkillsComplete ($this)) { |
|
171 | 171 | $status = 'complete'; |
172 | 172 | } |
173 | 173 | break; |
174 | 174 | case 'preview': |
175 | - if ($validator->basicsComplete($this) && |
|
176 | - $validator->experienceComplete($this) && |
|
177 | - $validator->essentialSkillsComplete($this) && |
|
178 | - $validator->assetSkillsComplete($this)) { |
|
175 | + if ($validator->basicsComplete ($this) && |
|
176 | + $validator->experienceComplete ($this) && |
|
177 | + $validator->essentialSkillsComplete ($this) && |
|
178 | + $validator->assetSkillsComplete ($this)) { |
|
179 | 179 | $status = 'complete'; |
180 | 180 | } |
181 | 181 | break; |
182 | 182 | case 'confirm': |
183 | - if ($validator->affirmationComplete($this)) { |
|
183 | + if ($validator->affirmationComplete ($this)) { |
|
184 | 184 | $status = 'complete'; |
185 | 185 | } |
186 | 186 | break; |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function meetsEssentialCriteria(): bool |
202 | 202 | { |
203 | - $essentialCriteria = $this->job_poster->criteria->filter( |
|
204 | - function ($value, $key) { |
|
203 | + $essentialCriteria = $this->job_poster->criteria->filter ( |
|
204 | + function ($value, $key){ |
|
205 | 205 | return $value->criteria_type->name == 'essential'; |
206 | 206 | } |
207 | 207 | ); |
208 | 208 | foreach ($essentialCriteria as $criterion) { |
209 | - $skillDeclaration = $this->skill_declarations->where("skill_id", $criterion->skill_id)->first(); |
|
209 | + $skillDeclaration = $this->skill_declarations->where ("skill_id", $criterion->skill_id)->first (); |
|
210 | 210 | if ($skillDeclaration === null || |
211 | 211 | $skillDeclaration->skill_level_id < $criterion->skill_level_id) { |
212 | 212 | return false; |
@@ -223,6 +223,6 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function getMeetsEssentialCriteriaAttribute():bool |
225 | 225 | { |
226 | - return $this->meetsEssentialCriteria(); |
|
226 | + return $this->meetsEssentialCriteria (); |
|
227 | 227 | } |
228 | 228 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @property \App\Models\Applicant $applicant |
21 | 21 | * @property \App\Models\Lookup\ApplicantProfileQuestion $applicant_profile_question |
22 | 22 | */ |
23 | -class ApplicantProfileAnswer extends BaseModel { |
|
23 | +class ApplicantProfileAnswer extends BaseModel{ |
|
24 | 24 | |
25 | 25 | protected $casts = [ |
26 | 26 | 'applicant_id' => 'int', |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | 'applicant_profile_question' |
35 | 35 | ]; |
36 | 36 | |
37 | - public function applicant() { |
|
38 | - return $this->belongsTo(\App\Models\Applicant::class); |
|
37 | + public function applicant(){ |
|
38 | + return $this->belongsTo (\App\Models\Applicant::class); |
|
39 | 39 | } |
40 | 40 | |
41 | - public function applicant_profile_question() { |
|
42 | - return $this->belongsTo(\App\Models\Lookup\ApplicantProfileQuestion::class); |
|
41 | + public function applicant_profile_question(){ |
|
42 | + return $this->belongsTo (\App\Models\Lookup\ApplicantProfileQuestion::class); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @property \App\Models\JobApplication $job_application |
21 | 21 | * @property \App\Models\JobPosterQuestion $job_poster_question |
22 | 22 | */ |
23 | -class JobApplicationAnswer extends BaseModel { |
|
23 | +class JobApplicationAnswer extends BaseModel{ |
|
24 | 24 | |
25 | 25 | protected $casts = [ |
26 | 26 | 'job_poster_questions_id' => 'int', |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | 'answer' |
31 | 31 | ]; |
32 | 32 | |
33 | - public function job_application() { |
|
34 | - return $this->belongsTo(\App\Models\JobApplication::class); |
|
33 | + public function job_application(){ |
|
34 | + return $this->belongsTo (\App\Models\JobApplication::class); |
|
35 | 35 | } |
36 | 36 | |
37 | - public function job_poster_question() { |
|
38 | - return $this->belongsTo(\App\Models\JobPosterQuestion::class); |
|
37 | + public function job_poster_question(){ |
|
38 | + return $this->belongsTo (\App\Models\JobPosterQuestion::class); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @property \App\Models\WorkEnvironment $work_environment |
22 | 22 | * @property \App\Models\WorkplacePhoto $workplace_photo |
23 | 23 | */ |
24 | -class WorkplacePhotoCaption extends BaseModel { |
|
24 | +class WorkplacePhotoCaption extends BaseModel{ |
|
25 | 25 | |
26 | 26 | protected $casts = [ |
27 | 27 | 'work_environment_id' => 'int', |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | 'description' |
33 | 33 | ]; |
34 | 34 | |
35 | - public function work_environment() { |
|
36 | - return $this->belongsTo(\App\Models\WorkEnvironment::class); |
|
35 | + public function work_environment(){ |
|
36 | + return $this->belongsTo (\App\Models\WorkEnvironment::class); |
|
37 | 37 | } |
38 | 38 | |
39 | - public function workplace_photo() { |
|
40 | - return $this->belongsTo(\App\Models\WorkplacePhoto::class); |
|
39 | + public function workplace_photo(){ |
|
40 | + return $this->belongsTo (\App\Models\WorkplacePhoto::class); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | } |
@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | use App\Services\Validation\Rules\ContainsObjectWithAttributeRule; |
14 | 14 | use App\Services\Validation\JobApplicationAnswerValidator; |
15 | 15 | |
16 | -class ApplicationValidator { |
|
16 | +class ApplicationValidator{ |
|
17 | 17 | |
18 | 18 | protected $citizenship_ids; |
19 | 19 | protected $veteran_status_ids; |
20 | 20 | protected $preferred_language_ids; |
21 | 21 | |
22 | - public function __construct() { |
|
23 | - $this->citizenship_ids = CitizenshipDeclaration::all()->pluck('id')->toArray(); |
|
24 | - $this->veteran_status_ids = VeteranStatus::all()->pluck('id')->toArray(); |
|
25 | - $this->preferred_language_ids = PreferredLanguage::all()->pluck('id')->toArray(); |
|
22 | + public function __construct(){ |
|
23 | + $this->citizenship_ids = CitizenshipDeclaration::all ()->pluck ('id')->toArray (); |
|
24 | + $this->veteran_status_ids = VeteranStatus::all ()->pluck ('id')->toArray (); |
|
25 | + $this->preferred_language_ids = PreferredLanguage::all ()->pluck ('id')->toArray (); |
|
26 | 26 | } |
27 | 27 | |
28 | - public function validate(JobApplication $application) { |
|
28 | + public function validate(JobApplication $application){ |
|
29 | 29 | |
30 | 30 | $backendRules = [ |
31 | 31 | 'job_poster_id' => 'required', |
@@ -33,30 +33,30 @@ discard block |
||
33 | 33 | 'applicant_id' => 'required' |
34 | 34 | ]; |
35 | 35 | |
36 | - $rules = array_merge( |
|
36 | + $rules = array_merge ( |
|
37 | 37 | $backendRules, |
38 | 38 | //$this->basicsValidator($application)->getRules(), |
39 | - $this->experienceValidator($application)->getRules(), |
|
39 | + $this->experienceValidator ($application)->getRules (), |
|
40 | 40 | //$this->essentialSkillsValidator($application)->getRules(), |
41 | - $this->affirmationValidator($application)->getRules() |
|
41 | + $this->affirmationValidator ($application)->getRules () |
|
42 | 42 | ); |
43 | 43 | |
44 | - $data = $application->toArray(); |
|
44 | + $data = $application->toArray (); |
|
45 | 45 | |
46 | 46 | // Combining and simplifiying error messages |
47 | - $rules = array_merge( |
|
47 | + $rules = array_merge ( |
|
48 | 48 | $rules, |
49 | 49 | ['application_step_1' => 'required|boolean|accepted'], |
50 | 50 | ['application_step_3' => 'required|boolean|accepted'] |
51 | 51 | ); |
52 | - $data = array_merge( |
|
52 | + $data = array_merge ( |
|
53 | 53 | $data, |
54 | - ['application_step_1' => $this->basicsComplete($application)], |
|
55 | - ['application_step_3' => $this->essentialSkillsComplete($application)] |
|
54 | + ['application_step_1' => $this->basicsComplete ($application)], |
|
55 | + ['application_step_3' => $this->essentialSkillsComplete ($application)] |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | //Validate basic data is filled in |
59 | - Validator::make($data, $rules)->validate(); |
|
59 | + Validator::make ($data, $rules)->validate (); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -70,110 +70,110 @@ discard block |
||
70 | 70 | { |
71 | 71 | $newArray = []; |
72 | 72 | foreach ($array as $key => $value) { |
73 | - $newArray[$fn($key)] = $value; |
|
73 | + $newArray[$fn ($key)] = $value; |
|
74 | 74 | } |
75 | 75 | return $newArray; |
76 | 76 | } |
77 | 77 | |
78 | - protected function addNestedValidatorRules($nestedAttribute, $validatorRules, $rules = []) { |
|
78 | + protected function addNestedValidatorRules($nestedAttribute, $validatorRules, $rules = []){ |
|
79 | 79 | // prepend the attribute name of each validator rule with the nested attribute name |
80 | - $newRules = $this->arrayMapKeys(function($key) use ($nestedAttribute) { |
|
81 | - return implode('.', [$nestedAttribute, $key]); |
|
80 | + $newRules = $this->arrayMapKeys (function ($key) use ($nestedAttribute) { |
|
81 | + return implode ('.', [$nestedAttribute, $key]); |
|
82 | 82 | }, |
83 | 83 | $validatorRules); |
84 | 84 | //Merge new rules with old rules |
85 | - $rules = array_merge($rules, $newRules); |
|
85 | + $rules = array_merge ($rules, $newRules); |
|
86 | 86 | return $rules; |
87 | 87 | } |
88 | 88 | |
89 | - public function basicsValidator(JobApplication $application) { |
|
89 | + public function basicsValidator(JobApplication $application){ |
|
90 | 90 | // Validate the fields common to every application |
91 | 91 | $rules = [ |
92 | 92 | 'language_requirement_confirmed' => ['required', 'boolean'], |
93 | - 'citizenship_declaration_id' => ['required', Rule::in($this->citizenship_ids)], |
|
94 | - 'veteran_status_id' => ['required', Rule::in($this->veteran_status_ids)], |
|
95 | - 'preferred_language_id' => ['required', Rule::in($this->preferred_language_ids)], |
|
93 | + 'citizenship_declaration_id' => ['required', Rule::in ($this->citizenship_ids)], |
|
94 | + 'veteran_status_id' => ['required', Rule::in ($this->veteran_status_ids)], |
|
95 | + 'preferred_language_id' => ['required', Rule::in ($this->preferred_language_ids)], |
|
96 | 96 | ]; |
97 | 97 | |
98 | 98 | //Load application answers so they are included in application->toArray() |
99 | - $application->load('job_application_answers'); |
|
99 | + $application->load ('job_application_answers'); |
|
100 | 100 | |
101 | 101 | // Validate that each question has been answered |
102 | 102 | $jobPosterQuestionRules = []; |
103 | - foreach($application->job_poster->job_poster_questions as $question) { |
|
104 | - $jobPosterQuestionRules[] = new ContainsObjectWithAttributeRule('job_poster_question_id', $question->id); |
|
103 | + foreach ($application->job_poster->job_poster_questions as $question) { |
|
104 | + $jobPosterQuestionRules[] = new ContainsObjectWithAttributeRule ('job_poster_question_id', $question->id); |
|
105 | 105 | } |
106 | 106 | $rules['job_application_answers'] = $jobPosterQuestionRules; |
107 | - $answerValidatorFactory = new JobApplicationAnswerValidator($application); |
|
107 | + $answerValidatorFactory = new JobApplicationAnswerValidator ($application); |
|
108 | 108 | |
109 | 109 | //Validate that each answer is complete |
110 | - foreach($application->job_application_answers as $key=>$answer) { |
|
111 | - $attribute = implode('.', ['job_application_answers', $key]); |
|
112 | - $rules = $this->addNestedValidatorRules($attribute, $answerValidatorFactory->rules(), $rules); |
|
110 | + foreach ($application->job_application_answers as $key=>$answer) { |
|
111 | + $attribute = implode ('.', ['job_application_answers', $key]); |
|
112 | + $rules = $this->addNestedValidatorRules ($attribute, $answerValidatorFactory->rules (), $rules); |
|
113 | 113 | } |
114 | 114 | |
115 | - $validator = Validator::make($application->toArray(), $rules); |
|
115 | + $validator = Validator::make ($application->toArray (), $rules); |
|
116 | 116 | return $validator; |
117 | 117 | } |
118 | 118 | |
119 | - public function basicsComplete(JobApplication $application) { |
|
120 | - $validator = $this->basicsValidator($application); |
|
121 | - return $validator->passes(); |
|
119 | + public function basicsComplete(JobApplication $application){ |
|
120 | + $validator = $this->basicsValidator ($application); |
|
121 | + return $validator->passes (); |
|
122 | 122 | } |
123 | 123 | |
124 | - public function experienceValidator(JobApplication $application) { |
|
124 | + public function experienceValidator(JobApplication $application){ |
|
125 | 125 | $rules = ['experience_saved' => 'required|boolean|accepted']; |
126 | - return Validator::make($application->toArray(), $rules); |
|
126 | + return Validator::make ($application->toArray (), $rules); |
|
127 | 127 | } |
128 | 128 | |
129 | - public function experienceComplete(JobApplication $application) { |
|
130 | - return $this->experienceValidator($application)->passes(); |
|
129 | + public function experienceComplete(JobApplication $application){ |
|
130 | + return $this->experienceValidator ($application)->passes (); |
|
131 | 131 | } |
132 | 132 | |
133 | - protected function skillsValidator(JobApplication $application, $criteria_type) { |
|
133 | + protected function skillsValidator(JobApplication $application, $criteria_type){ |
|
134 | 134 | $rules = []; |
135 | 135 | |
136 | 136 | $skillDeclarationRules = []; |
137 | - $criteriaTypeId = CriteriaType::where('name', $criteria_type)->firstOrFail()->id; |
|
138 | - foreach($application->job_poster->criteria->where('criteria_type_id', $criteriaTypeId) as $criteria) { |
|
137 | + $criteriaTypeId = CriteriaType::where ('name', $criteria_type)->firstOrFail ()->id; |
|
138 | + foreach ($application->job_poster->criteria->where ('criteria_type_id', $criteriaTypeId) as $criteria) { |
|
139 | 139 | //Validate that every essential skill has a corresponding declaration |
140 | - $skillDeclarationRules[] = new ContainsObjectWithAttributeRule('skill_id', $criteria->skill_id); |
|
140 | + $skillDeclarationRules[] = new ContainsObjectWithAttributeRule ('skill_id', $criteria->skill_id); |
|
141 | 141 | } |
142 | 142 | $rules['skill_declarations'] = $skillDeclarationRules; |
143 | - $application->applicant->load('skill_declarations'); |
|
143 | + $application->applicant->load ('skill_declarations'); |
|
144 | 144 | |
145 | 145 | //Validate that those declarations are complete |
146 | - $skilDeclarationValidatorFactory = new SkillDeclarationValidator($application->applicant); |
|
147 | - $relevantSkillIds = $application->job_poster->criteria->where('criteria_type_id', $criteriaTypeId)->pluck('skill_id'); |
|
148 | - foreach( $application->skill_declarations as $key=>$declaration) { |
|
149 | - if ($relevantSkillIds->contains($declaration->skill_id)) { |
|
150 | - $attribute = implode('.', ['skill_declarations', $key]); |
|
151 | - $skillDeclarationValidator = $skilDeclarationValidatorFactory->validator($declaration); |
|
152 | - $rules = $this->addNestedValidatorRules($attribute, $skillDeclarationValidator->getRules(), $rules); |
|
146 | + $skilDeclarationValidatorFactory = new SkillDeclarationValidator ($application->applicant); |
|
147 | + $relevantSkillIds = $application->job_poster->criteria->where ('criteria_type_id', $criteriaTypeId)->pluck ('skill_id'); |
|
148 | + foreach ($application->skill_declarations as $key=>$declaration) { |
|
149 | + if ($relevantSkillIds->contains ($declaration->skill_id)) { |
|
150 | + $attribute = implode ('.', ['skill_declarations', $key]); |
|
151 | + $skillDeclarationValidator = $skilDeclarationValidatorFactory->validator ($declaration); |
|
152 | + $rules = $this->addNestedValidatorRules ($attribute, $skillDeclarationValidator->getRules (), $rules); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - $validator = Validator::make($application->toArray(), $rules); |
|
156 | + $validator = Validator::make ($application->toArray (), $rules); |
|
157 | 157 | return $validator; |
158 | 158 | } |
159 | 159 | |
160 | - public function essentialSkillsValidator(JobApplication $application) { |
|
161 | - return $this->skillsValidator($application, 'essential'); |
|
160 | + public function essentialSkillsValidator(JobApplication $application){ |
|
161 | + return $this->skillsValidator ($application, 'essential'); |
|
162 | 162 | } |
163 | 163 | |
164 | - public function essentialSkillsComplete(JobApplication $application) { |
|
165 | - return $this->essentialSkillsValidator($application)->passes(); |
|
164 | + public function essentialSkillsComplete(JobApplication $application){ |
|
165 | + return $this->essentialSkillsValidator ($application)->passes (); |
|
166 | 166 | } |
167 | 167 | |
168 | - public function assetSkillsValidator(JobApplication $application) { |
|
169 | - return $this->skillsValidator($application, 'asset'); |
|
168 | + public function assetSkillsValidator(JobApplication $application){ |
|
169 | + return $this->skillsValidator ($application, 'asset'); |
|
170 | 170 | } |
171 | 171 | |
172 | - public function assetSkillsComplete(JobApplication $application) { |
|
173 | - return $this->assetSkillsValidator($application)->passes(); |
|
172 | + public function assetSkillsComplete(JobApplication $application){ |
|
173 | + return $this->assetSkillsValidator ($application)->passes (); |
|
174 | 174 | } |
175 | 175 | |
176 | - public function affirmationValidator(JobApplication $application) { |
|
176 | + public function affirmationValidator(JobApplication $application){ |
|
177 | 177 | $rules = [ |
178 | 178 | 'submission_signature' => [ |
179 | 179 | 'required', |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | 'max:191', |
187 | 187 | ] |
188 | 188 | ]; |
189 | - return Validator::make($application->toArray(), $rules); |
|
189 | + return Validator::make ($application->toArray (), $rules); |
|
190 | 190 | } |
191 | 191 | |
192 | - public function affirmationComplete(JobApplication $application) { |
|
193 | - return $this->affirmationValidator($application)->passes(); |
|
192 | + public function affirmationComplete(JobApplication $application){ |
|
193 | + return $this->affirmationValidator ($application)->passes (); |
|
194 | 194 | } |
195 | 195 | } |
@@ -7,42 +7,42 @@ |
||
7 | 7 | use Illuminate\Support\Facades\Validator; |
8 | 8 | use Illuminate\Validation\Rule; |
9 | 9 | |
10 | -class JobApplicationAnswerValidator { |
|
10 | +class JobApplicationAnswerValidator{ |
|
11 | 11 | |
12 | 12 | protected $application; |
13 | 13 | protected $questionIds; |
14 | 14 | |
15 | - public function __construct(JobApplication $application) { |
|
15 | + public function __construct(JobApplication $application){ |
|
16 | 16 | $this->application = $application; |
17 | - $this->questionIds = $application->job_poster->job_poster_questions->pluck('id')->toArray(); |
|
17 | + $this->questionIds = $application->job_poster->job_poster_questions->pluck ('id')->toArray (); |
|
18 | 18 | } |
19 | 19 | |
20 | - public function rules() { |
|
20 | + public function rules(){ |
|
21 | 21 | $rules = [ |
22 | 22 | 'answer' => 'required|string', |
23 | 23 | 'job_poster_question_id' => [ |
24 | 24 | 'required', |
25 | - Rule::in($this->questionIds), |
|
25 | + Rule::in ($this->questionIds), |
|
26 | 26 | ], |
27 | 27 | 'job_application_id' => [ |
28 | 28 | 'required', |
29 | - Rule::in([$this->application->id]), |
|
29 | + Rule::in ([$this->application->id]), |
|
30 | 30 | ] |
31 | 31 | ]; |
32 | 32 | return $rules; |
33 | 33 | } |
34 | 34 | |
35 | - public function validator(JobApplicationAnswer $answer) { |
|
35 | + public function validator(JobApplicationAnswer $answer){ |
|
36 | 36 | |
37 | 37 | |
38 | - return Validator::make($answer->toArray(), $this->rules()); |
|
38 | + return Validator::make ($answer->toArray (), $this->rules ()); |
|
39 | 39 | } |
40 | 40 | |
41 | - public function validate(JobApplicationAnswer $answer) { |
|
42 | - return $this->validator($answer)->validate(); |
|
41 | + public function validate(JobApplicationAnswer $answer){ |
|
42 | + return $this->validator ($answer)->validate (); |
|
43 | 43 | } |
44 | 44 | |
45 | - public function isComplete(JobApplicationAnswer $answer) { |
|
46 | - return $this->validator($answer)->passes(); |
|
45 | + public function isComplete(JobApplicationAnswer $answer){ |
|
46 | + return $this->validator ($answer)->passes (); |
|
47 | 47 | } |
48 | 48 | } |
@@ -23,33 +23,33 @@ discard block |
||
23 | 23 | public function __construct(Applicant $applicant) |
24 | 24 | { |
25 | 25 | $this->applicant = $applicant; |
26 | - $this->skill_ids = Skill::all()->pluck('id'); |
|
27 | - $this->skill_status_ids = SkillStatus::all()->pluck('id'); |
|
28 | - $this->skill_level_ids = SkillLevel::all()->pluck('id'); |
|
26 | + $this->skill_ids = Skill::all ()->pluck ('id'); |
|
27 | + $this->skill_status_ids = SkillStatus::all ()->pluck ('id'); |
|
28 | + $this->skill_level_ids = SkillLevel::all ()->pluck ('id'); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
32 | - public function validator(SkillDeclaration $skillDeclaration) { |
|
33 | - $uniqueSkillRule = new UniqueApplicantSkillRule($this->applicant, $skillDeclaration->id); |
|
32 | + public function validator(SkillDeclaration $skillDeclaration){ |
|
33 | + $uniqueSkillRule = new UniqueApplicantSkillRule ($this->applicant, $skillDeclaration->id); |
|
34 | 34 | |
35 | 35 | //Validate basic data is filled in |
36 | - $validator = Validator::make($skillDeclaration->getAttributes(), [ |
|
36 | + $validator = Validator::make ($skillDeclaration->getAttributes (), [ |
|
37 | 37 | 'skill_id' => [ |
38 | 38 | 'required', |
39 | - Rule::in($this->skill_ids->toArray()), |
|
39 | + Rule::in ($this->skill_ids->toArray ()), |
|
40 | 40 | $uniqueSkillRule, |
41 | 41 | ], |
42 | 42 | 'applicant_id' => [ |
43 | 43 | 'required', |
44 | - Rule::in([$this->applicant->id]), |
|
44 | + Rule::in ([$this->applicant->id]), |
|
45 | 45 | ], |
46 | 46 | 'skill_status_id' => [ |
47 | 47 | 'required', |
48 | - Rule::in($this->skill_status_ids->toArray()), |
|
48 | + Rule::in ($this->skill_status_ids->toArray ()), |
|
49 | 49 | ], |
50 | 50 | 'skill_level_id' => [ |
51 | 51 | 'required', |
52 | - Rule::in($this->skill_level_ids->toArray()), |
|
52 | + Rule::in ($this->skill_level_ids->toArray ()), |
|
53 | 53 | ], |
54 | 54 | 'description' => 'required|string', |
55 | 55 | ]); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | public function validate(SkillDeclaration $skillDeclaration) |
60 | 60 | { |
61 | - return $this->validator($skillDeclaration)->validate(); |
|
61 | + return $this->validator ($skillDeclaration)->validate (); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 |