@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | protected $veteran_status_ids; |
| 21 | 21 | protected $preferred_language_ids; |
| 22 | 22 | |
| 23 | - public function __construct() |
|
| 23 | + public function __construct () |
|
| 24 | 24 | { |
| 25 | - $this->citizenship_ids = CitizenshipDeclaration::all()->pluck('id')->toArray(); |
|
| 26 | - $this->veteran_status_ids = VeteranStatus::all()->pluck('id')->toArray(); |
|
| 27 | - $this->preferred_language_ids = PreferredLanguage::all()->pluck('id')->toArray(); |
|
| 25 | + $this->citizenship_ids = CitizenshipDeclaration::all ()->pluck ('id')->toArray (); |
|
| 26 | + $this->veteran_status_ids = VeteranStatus::all ()->pluck ('id')->toArray (); |
|
| 27 | + $this->preferred_language_ids = PreferredLanguage::all ()->pluck ('id')->toArray (); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function validate(JobApplication $application) |
|
| 30 | + public function validate (JobApplication $application) |
|
| 31 | 31 | { |
| 32 | 32 | |
| 33 | 33 | $backendRules = [ |
@@ -36,30 +36,30 @@ discard block |
||
| 36 | 36 | 'applicant_id' => 'required' |
| 37 | 37 | ]; |
| 38 | 38 | |
| 39 | - $rules = array_merge( |
|
| 39 | + $rules = array_merge ( |
|
| 40 | 40 | $backendRules, |
| 41 | 41 | // $this->basicsValidator($application)->getRules(), |
| 42 | - $this->experienceValidator($application)->getRules(), |
|
| 42 | + $this->experienceValidator ($application)->getRules (), |
|
| 43 | 43 | // $this->essentialSkillsValidator($application)->getRules(), |
| 44 | - $this->affirmationValidator($application)->getRules() |
|
| 44 | + $this->affirmationValidator ($application)->getRules () |
|
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | - $data = $application->toArray(); |
|
| 47 | + $data = $application->toArray (); |
|
| 48 | 48 | |
| 49 | 49 | // Combining and simplifiying error messages |
| 50 | - $rules = array_merge( |
|
| 50 | + $rules = array_merge ( |
|
| 51 | 51 | $rules, |
| 52 | 52 | ['application_step_1' => 'required|boolean|accepted'], |
| 53 | 53 | ['application_step_3' => 'required|boolean|accepted'] |
| 54 | 54 | ); |
| 55 | - $data = array_merge( |
|
| 55 | + $data = array_merge ( |
|
| 56 | 56 | $data, |
| 57 | - ['application_step_1' => $this->basicsComplete($application)], |
|
| 58 | - ['application_step_3' => $this->essentialSkillsComplete($application)] |
|
| 57 | + ['application_step_1' => $this->basicsComplete ($application)], |
|
| 58 | + ['application_step_3' => $this->essentialSkillsComplete ($application)] |
|
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | 61 | // Validate basic data is filled in |
| 62 | - Validator::make($data, $rules)->validate(); |
|
| 62 | + Validator::make ($data, $rules)->validate (); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -69,124 +69,124 @@ discard block |
||
| 69 | 69 | * @param array $array Array to operate on. |
| 70 | 70 | * @return array |
| 71 | 71 | */ |
| 72 | - protected function arrayMapKeys($fn, $array): array |
|
| 72 | + protected function arrayMapKeys ($fn, $array): array |
|
| 73 | 73 | { |
| 74 | 74 | $newArray = []; |
| 75 | 75 | foreach ($array as $key => $value) { |
| 76 | - $newArray[$fn($key)] = $value; |
|
| 76 | + $newArray[$fn ($key)] = $value; |
|
| 77 | 77 | } |
| 78 | 78 | return $newArray; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - protected function addNestedValidatorRules($nestedAttribute, $validatorRules, $rules = []) |
|
| 81 | + protected function addNestedValidatorRules ($nestedAttribute, $validatorRules, $rules = []) |
|
| 82 | 82 | { |
| 83 | 83 | // prepend the attribute name of each validator rule with the nested attribute name |
| 84 | - $newRules = $this->arrayMapKeys(function($key) use ($nestedAttribute) { |
|
| 85 | - return implode('.', [$nestedAttribute, $key]); |
|
| 84 | + $newRules = $this->arrayMapKeys (function ($key) use ($nestedAttribute) { |
|
| 85 | + return implode ('.', [$nestedAttribute, $key]); |
|
| 86 | 86 | }, |
| 87 | 87 | $validatorRules); |
| 88 | 88 | // Merge new rules with old rules |
| 89 | - $rules = array_merge($rules, $newRules); |
|
| 89 | + $rules = array_merge ($rules, $newRules); |
|
| 90 | 90 | return $rules; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function basicsValidator(JobApplication $application) |
|
| 93 | + public function basicsValidator (JobApplication $application) |
|
| 94 | 94 | { |
| 95 | 95 | // Validate the fields common to every application |
| 96 | 96 | $rules = [ |
| 97 | 97 | 'language_requirement_confirmed' => ['required', 'boolean'], |
| 98 | - 'citizenship_declaration_id' => ['required', Rule::in($this->citizenship_ids)], |
|
| 99 | - 'veteran_status_id' => ['required', Rule::in($this->veteran_status_ids)], |
|
| 100 | - 'preferred_language_id' => ['required', Rule::in($this->preferred_language_ids)], |
|
| 98 | + 'citizenship_declaration_id' => ['required', Rule::in ($this->citizenship_ids)], |
|
| 99 | + 'veteran_status_id' => ['required', Rule::in ($this->veteran_status_ids)], |
|
| 100 | + 'preferred_language_id' => ['required', Rule::in ($this->preferred_language_ids)], |
|
| 101 | 101 | ]; |
| 102 | 102 | |
| 103 | 103 | // Load application answers so they are included in application->toArray() |
| 104 | - $application->load('job_application_answers'); |
|
| 104 | + $application->load ('job_application_answers'); |
|
| 105 | 105 | |
| 106 | 106 | // Validate that each question has been answered |
| 107 | 107 | $jobPosterQuestionRules = []; |
| 108 | 108 | foreach ($application->job_poster->job_poster_questions as $question) { |
| 109 | - $jobPosterQuestionRules[] = new ContainsObjectWithAttributeRule('job_poster_question_id', $question->id); |
|
| 109 | + $jobPosterQuestionRules[] = new ContainsObjectWithAttributeRule ('job_poster_question_id', $question->id); |
|
| 110 | 110 | } |
| 111 | 111 | $rules['job_application_answers'] = $jobPosterQuestionRules; |
| 112 | - $answerValidatorFactory = new JobApplicationAnswerValidator($application); |
|
| 112 | + $answerValidatorFactory = new JobApplicationAnswerValidator ($application); |
|
| 113 | 113 | |
| 114 | 114 | // Validate that each answer is complete |
| 115 | 115 | foreach ($application->job_application_answers as $key => $answer) { |
| 116 | - $attribute = implode('.', ['job_application_answers', $key]); |
|
| 117 | - $rules = $this->addNestedValidatorRules($attribute, $answerValidatorFactory->rules(), $rules); |
|
| 116 | + $attribute = implode ('.', ['job_application_answers', $key]); |
|
| 117 | + $rules = $this->addNestedValidatorRules ($attribute, $answerValidatorFactory->rules (), $rules); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $validator = Validator::make($application->toArray(), $rules); |
|
| 120 | + $validator = Validator::make ($application->toArray (), $rules); |
|
| 121 | 121 | return $validator; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public function basicsComplete(JobApplication $application) |
|
| 124 | + public function basicsComplete (JobApplication $application) |
|
| 125 | 125 | { |
| 126 | - $validator = $this->basicsValidator($application); |
|
| 127 | - return $validator->passes(); |
|
| 126 | + $validator = $this->basicsValidator ($application); |
|
| 127 | + return $validator->passes (); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public function experienceValidator(JobApplication $application) |
|
| 130 | + public function experienceValidator (JobApplication $application) |
|
| 131 | 131 | { |
| 132 | 132 | $rules = ['experience_saved' => 'required|boolean|accepted']; |
| 133 | - return Validator::make($application->toArray(), $rules); |
|
| 133 | + return Validator::make ($application->toArray (), $rules); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public function experienceComplete(JobApplication $application) |
|
| 136 | + public function experienceComplete (JobApplication $application) |
|
| 137 | 137 | { |
| 138 | - return $this->experienceValidator($application)->passes(); |
|
| 138 | + return $this->experienceValidator ($application)->passes (); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - protected function skillsValidator(JobApplication $application, $criteria_type) |
|
| 141 | + protected function skillsValidator (JobApplication $application, $criteria_type) |
|
| 142 | 142 | { |
| 143 | 143 | $rules = []; |
| 144 | 144 | |
| 145 | 145 | $skillDeclarationRules = []; |
| 146 | - $criteriaTypeId = CriteriaType::where('name', $criteria_type)->firstOrFail()->id; |
|
| 147 | - foreach ($application->job_poster->criteria->where('criteria_type_id', $criteriaTypeId) as $criteria) { |
|
| 146 | + $criteriaTypeId = CriteriaType::where ('name', $criteria_type)->firstOrFail ()->id; |
|
| 147 | + foreach ($application->job_poster->criteria->where ('criteria_type_id', $criteriaTypeId) as $criteria) { |
|
| 148 | 148 | // Validate that every essential skill has a corresponding declaration |
| 149 | - $skillDeclarationRules[] = new ContainsObjectWithAttributeRule('skill_id', $criteria->skill_id); |
|
| 149 | + $skillDeclarationRules[] = new ContainsObjectWithAttributeRule ('skill_id', $criteria->skill_id); |
|
| 150 | 150 | } |
| 151 | 151 | $rules['skill_declarations'] = $skillDeclarationRules; |
| 152 | - $application->applicant->load('skill_declarations'); |
|
| 152 | + $application->applicant->load ('skill_declarations'); |
|
| 153 | 153 | |
| 154 | 154 | // Validate that those declarations are complete |
| 155 | - $skilDeclarationValidatorFactory = new SkillDeclarationValidator($application->applicant); |
|
| 156 | - $relevantSkillIds = $application->job_poster->criteria->where('criteria_type_id', $criteriaTypeId)->pluck('skill_id'); |
|
| 155 | + $skilDeclarationValidatorFactory = new SkillDeclarationValidator ($application->applicant); |
|
| 156 | + $relevantSkillIds = $application->job_poster->criteria->where ('criteria_type_id', $criteriaTypeId)->pluck ('skill_id'); |
|
| 157 | 157 | foreach ($application->skill_declarations as $key => $declaration) { |
| 158 | - if ($relevantSkillIds->contains($declaration->skill_id)) { |
|
| 159 | - $attribute = implode('.', ['skill_declarations', $key]); |
|
| 160 | - $skillDeclarationValidator = $skilDeclarationValidatorFactory->validator($declaration); |
|
| 161 | - $rules = $this->addNestedValidatorRules($attribute, $skillDeclarationValidator->getRules(), $rules); |
|
| 158 | + if ($relevantSkillIds->contains ($declaration->skill_id)) { |
|
| 159 | + $attribute = implode ('.', ['skill_declarations', $key]); |
|
| 160 | + $skillDeclarationValidator = $skilDeclarationValidatorFactory->validator ($declaration); |
|
| 161 | + $rules = $this->addNestedValidatorRules ($attribute, $skillDeclarationValidator->getRules (), $rules); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $validator = Validator::make($application->toArray(), $rules); |
|
| 165 | + $validator = Validator::make ($application->toArray (), $rules); |
|
| 166 | 166 | return $validator; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function essentialSkillsValidator(JobApplication $application) |
|
| 169 | + public function essentialSkillsValidator (JobApplication $application) |
|
| 170 | 170 | { |
| 171 | - return $this->skillsValidator($application, 'essential'); |
|
| 171 | + return $this->skillsValidator ($application, 'essential'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - public function essentialSkillsComplete(JobApplication $application) |
|
| 174 | + public function essentialSkillsComplete (JobApplication $application) |
|
| 175 | 175 | { |
| 176 | - return $this->essentialSkillsValidator($application)->passes(); |
|
| 176 | + return $this->essentialSkillsValidator ($application)->passes (); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public function assetSkillsValidator(JobApplication $application) |
|
| 179 | + public function assetSkillsValidator (JobApplication $application) |
|
| 180 | 180 | { |
| 181 | - return $this->skillsValidator($application, 'asset'); |
|
| 181 | + return $this->skillsValidator ($application, 'asset'); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function assetSkillsComplete(JobApplication $application) |
|
| 184 | + public function assetSkillsComplete (JobApplication $application) |
|
| 185 | 185 | { |
| 186 | - return $this->assetSkillsValidator($application)->passes(); |
|
| 186 | + return $this->assetSkillsValidator ($application)->passes (); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - public function affirmationValidator(JobApplication $application) |
|
| 189 | + public function affirmationValidator (JobApplication $application) |
|
| 190 | 190 | { |
| 191 | 191 | $rules = [ |
| 192 | 192 | 'submission_signature' => [ |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | 'max:191', |
| 201 | 201 | ] |
| 202 | 202 | ]; |
| 203 | - return Validator::make($application->toArray(), $rules); |
|
| 203 | + return Validator::make ($application->toArray (), $rules); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - public function affirmationComplete(JobApplication $application) |
|
| 206 | + public function affirmationComplete (JobApplication $application) |
|
| 207 | 207 | { |
| 208 | - return $this->affirmationValidator($application)->passes(); |
|
| 208 | + return $this->affirmationValidator ($application)->passes (); |
|
| 209 | 209 | } |
| 210 | 210 | } |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | * @param \Illuminate\Console\Scheduling\Schedule $schedule |
| 22 | 22 | * @return void |
| 23 | 23 | */ |
| 24 | - protected function schedule(Schedule $schedule): void |
|
| 24 | + protected function schedule (Schedule $schedule): void |
|
| 25 | 25 | { |
| 26 | 26 | // $schedule->command('inspire') |
| 27 | 27 | // ->hourly(); |
| 28 | 28 | // start the queue daemon, if its not running |
| 29 | - if (!$this->osProcessIsRunning('queue:work')) { |
|
| 30 | - $schedule->command('queue:work')->everyMinute(); |
|
| 29 | + if (!$this->osProcessIsRunning ('queue:work')) { |
|
| 30 | + $schedule->command ('queue:work')->everyMinute (); |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return void |
| 38 | 38 | */ |
| 39 | - protected function commands(): void |
|
| 39 | + protected function commands (): void |
|
| 40 | 40 | { |
| 41 | - $this->load(__DIR__ . '/Commands'); |
|
| 41 | + $this->load (__DIR__.'/Commands'); |
|
| 42 | 42 | |
| 43 | - require base_path('routes/console.php'); |
|
| 43 | + require base_path ('routes/console.php'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -49,17 +49,17 @@ discard block |
||
| 49 | 49 | * @param string $needle |
| 50 | 50 | * @return boolean |
| 51 | 51 | */ |
| 52 | - protected function osProcessIsRunning(string $needle): bool |
|
| 52 | + protected function osProcessIsRunning (string $needle): bool |
|
| 53 | 53 | { |
| 54 | 54 | // get process status. the "-ww"-option is important to get the full output! |
| 55 | - exec('ps aux -ww', $process_status); |
|
| 55 | + exec ('ps aux -ww', $process_status); |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | // search $needle in process status |
| 59 | - $result = array_filter( |
|
| 59 | + $result = array_filter ( |
|
| 60 | 60 | $process_status, |
| 61 | - function($var) use ($needle) { |
|
| 62 | - return strpos($var, $needle); |
|
| 61 | + function ($var) use ($needle) { |
|
| 62 | + return strpos ($var, $needle); |
|
| 63 | 63 | } |
| 64 | 64 | ); |
| 65 | 65 | |
@@ -12,12 +12,12 @@ |
||
| 12 | 12 | * @param \Illuminate\Http\Request $request |
| 13 | 13 | * @return string |
| 14 | 14 | */ |
| 15 | - protected function redirectTo($request) |
|
| 15 | + protected function redirectTo ($request) |
|
| 16 | 16 | { |
| 17 | - if (WhichPortal::isManagerPortal()) { |
|
| 18 | - return route('manager.login'); |
|
| 17 | + if (WhichPortal::isManagerPortal ()) { |
|
| 18 | + return route ('manager.login'); |
|
| 19 | 19 | } else { |
| 20 | - return route('login'); |
|
| 20 | + return route ('login'); |
|
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | } |