@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * Class constructor. |
15 | 15 | */ |
16 | - public function __construct() |
|
16 | + public function __construct () |
|
17 | 17 | { |
18 | 18 | // This applies the appropriate policy to each resource route. |
19 | - $this->authorizeResource(Manager::class, 'manager'); |
|
19 | + $this->authorizeResource (Manager::class, 'manager'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return \Illuminate\Http\Response |
26 | 26 | */ |
27 | - public function index() |
|
27 | + public function index () |
|
28 | 28 | { |
29 | 29 | // TODO: complete. |
30 | 30 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param \Illuminate\Http\Request $request Incoming Request. |
36 | 36 | * @return \Illuminate\Http\Response |
37 | 37 | */ |
38 | - public function store(Request $request) |
|
38 | + public function store (Request $request) |
|
39 | 39 | { |
40 | 40 | // TODO: complete. |
41 | 41 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @param \App\Models\Manager $manager Incoming Manager. |
47 | 47 | * @return \Illuminate\Http\Response |
48 | 48 | */ |
49 | - public function show(Manager $manager) |
|
49 | + public function show (Manager $manager) |
|
50 | 50 | { |
51 | - return response()->json($manager->toApiArray()); |
|
51 | + return response ()->json ($manager->toApiArray ()); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return \Illuminate\Http\Response |
58 | 58 | */ |
59 | - public function showAuthenticated() |
|
59 | + public function showAuthenticated () |
|
60 | 60 | { |
61 | - $user = Auth::user(); |
|
61 | + $user = Auth::user (); |
|
62 | 62 | if ($user !== null && $user->manager !== null) { |
63 | - return response()->json($user->manager->toApiArray()); |
|
63 | + return response ()->json ($user->manager->toApiArray ()); |
|
64 | 64 | } |
65 | - return response()->json([]); |
|
65 | + return response ()->json ([]); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | * @param \App\Models\Manager $manager Incoming Manager. |
73 | 73 | * @return \Illuminate\Http\Response |
74 | 74 | */ |
75 | - public function update(UpdateManagerApi $request, Manager $manager) |
|
75 | + public function update (UpdateManagerApi $request, Manager $manager) |
|
76 | 76 | { |
77 | - $validated = $request->validated(); |
|
78 | - $manager->fill($validated); |
|
79 | - $manager->save(); |
|
80 | - return response()->json($manager->toApiArray()); |
|
77 | + $validated = $request->validated (); |
|
78 | + $manager->fill ($validated); |
|
79 | + $manager->save (); |
|
80 | + return response ()->json ($manager->toApiArray ()); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param \App\Models\Manager $manager Incoming Manager. |
87 | 87 | * @return \Illuminate\Http\Response |
88 | 88 | */ |
89 | - public function destroy(Manager $manager) |
|
89 | + public function destroy (Manager $manager) |
|
90 | 90 | { |
91 | 91 | // TODO: complete. |
92 | 92 | } |
@@ -12,8 +12,8 @@ |
||
12 | 12 | * |
13 | 13 | * @return mixed |
14 | 14 | */ |
15 | - public function index() |
|
15 | + public function index () |
|
16 | 16 | { |
17 | - return Department::all()->map->toApiArray(); |
|
17 | + return Department::all ()->map->toApiArray (); |
|
18 | 18 | } |
19 | 19 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * Class constructor |
21 | 21 | */ |
22 | - public function __construct() |
|
22 | + public function __construct () |
|
23 | 23 | { |
24 | 24 | // This applies the appropriate policy to each resource route. |
25 | - $this->authorizeResource(JobPoster::class, 'job'); |
|
25 | + $this->authorizeResource (JobPoster::class, 'job'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | * @param \App\Models\JobPoster $job Incoming Job Poster object. |
34 | 34 | * @return mixed[] |
35 | 35 | */ |
36 | - private function jobToArray(JobPoster $job) |
|
36 | + private function jobToArray (JobPoster $job) |
|
37 | 37 | { |
38 | - $criteria = Criteria::where('job_poster_id', $job->id)->get(); |
|
38 | + $criteria = Criteria::where ('job_poster_id', $job->id)->get (); |
|
39 | 39 | |
40 | 40 | $toApiArray = function ($model) { |
41 | - return array_merge($model->toArray(), $model->getTranslationsArray()); |
|
41 | + return array_merge ($model->toArray (), $model->getTranslationsArray ()); |
|
42 | 42 | }; |
43 | - $criteriaTranslated = $criteria->map($toApiArray); |
|
43 | + $criteriaTranslated = $criteria->map ($toApiArray); |
|
44 | 44 | |
45 | - $jobArray = array_merge($job->toApiArray(), ['criteria' => $criteriaTranslated]); |
|
45 | + $jobArray = array_merge ($job->toApiArray (), ['criteria' => $criteriaTranslated]); |
|
46 | 46 | return $jobArray; |
47 | 47 | } |
48 | 48 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return \Illuminate\Http\Response |
52 | 52 | */ |
53 | - public function index() |
|
53 | + public function index () |
|
54 | 54 | { |
55 | 55 | // TODO: complete. |
56 | 56 | } |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | * @param \App\Http\Requests\StoreJobPoster $request Incoming request. |
62 | 62 | * @return \Illuminate\Http\Response |
63 | 63 | */ |
64 | - public function store(StoreJobPoster $request) |
|
64 | + public function store (StoreJobPoster $request) |
|
65 | 65 | { |
66 | - $data = $request->validated(); |
|
67 | - $job = new JobPoster(); |
|
68 | - $job->manager_id = $request->user()->manager->id; |
|
66 | + $data = $request->validated (); |
|
67 | + $job = new JobPoster (); |
|
68 | + $job->manager_id = $request->user ()->manager->id; |
|
69 | 69 | // Defaulting JPB created Jobs to monthly terms for now. |
70 | - $job->job_term_id = JobTerm::where('name', 'month')->value('id'); |
|
71 | - $job->fill($data); |
|
72 | - $job->save(); |
|
73 | - return response()->json($this->jobToArray($job)); |
|
70 | + $job->job_term_id = JobTerm::where ('name', 'month')->value ('id'); |
|
71 | + $job->fill ($data); |
|
72 | + $job->save (); |
|
73 | + return response ()->json ($this->jobToArray ($job)); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @param \App\Models\JobPoster $job Incoming Job Poster. |
80 | 80 | * @return \Illuminate\Http\Response |
81 | 81 | */ |
82 | - public function show(JobPoster $job) |
|
82 | + public function show (JobPoster $job) |
|
83 | 83 | { |
84 | - return response()->json($this->jobToArray($job)); |
|
84 | + return response ()->json ($this->jobToArray ($job)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | * @param \App\Models\JobPoster $job Incoming Job Poster. |
92 | 92 | * @return \Illuminate\Http\Response |
93 | 93 | */ |
94 | - public function update(UpdateJobPoster $request, JobPoster $job) |
|
94 | + public function update (UpdateJobPoster $request, JobPoster $job) |
|
95 | 95 | { |
96 | - $data = $request->validated(); |
|
96 | + $data = $request->validated (); |
|
97 | 97 | // Only values both in the JobPoster->fillable array, |
98 | 98 | // and returned by UpdateJobPoster->validatedData(), will be set. |
99 | - $job->fill($data); |
|
99 | + $job->fill ($data); |
|
100 | 100 | // Defaulting JPB updated jobs to monthly for now. |
101 | - $job->job_term_id = JobTerm::where('name', 'month')->value('id'); |
|
102 | - $job->save(); |
|
103 | - return response()->json($this->jobToArray($job->fresh())); |
|
101 | + $job->job_term_id = JobTerm::where ('name', 'month')->value ('id'); |
|
102 | + $job->save (); |
|
103 | + return response ()->json ($this->jobToArray ($job->fresh ())); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param integer $id Job Poster ID. |
110 | 110 | * @return \Illuminate\Http\Response |
111 | 111 | */ |
112 | - public function destroy($id) |
|
112 | + public function destroy ($id) |
|
113 | 113 | { |
114 | 114 | // TODO: complete. |
115 | 115 | } |
@@ -120,23 +120,23 @@ discard block |
||
120 | 120 | * @param \App\Models\JobPoster $job Job Poster object. |
121 | 121 | * @return \Illuminate\Http\Response |
122 | 122 | */ |
123 | - public function submitForReview(JobPoster $job) |
|
123 | + public function submitForReview (JobPoster $job) |
|
124 | 124 | { |
125 | 125 | // Check to avoid submitting for review multiple times. |
126 | 126 | if ($job->review_requested_at === null) { |
127 | 127 | // Update review request timestamp. |
128 | - $job->review_requested_at = new Date(); |
|
129 | - $job->save(); |
|
128 | + $job->review_requested_at = new Date (); |
|
129 | + $job->save (); |
|
130 | 130 | |
131 | 131 | // Send email. |
132 | - $reviewer_email = config('mail.reviewer_email'); |
|
132 | + $reviewer_email = config ('mail.reviewer_email'); |
|
133 | 133 | if (isset($reviewer_email)) { |
134 | - Mail::to($reviewer_email)->send(new JobPosterReviewRequested($job, Auth::user())); |
|
134 | + Mail::to ($reviewer_email)->send (new JobPosterReviewRequested ($job, Auth::user ())); |
|
135 | 135 | } else { |
136 | - Log::error('The reviewer email environment variable is not set.'); |
|
136 | + Log::error ('The reviewer email environment variable is not set.'); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - return response()->json($this->jobToArray($job)); |
|
140 | + return response ()->json ($this->jobToArray ($job)); |
|
141 | 141 | } |
142 | 142 | } |
@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | * @param JobPosterKeyTask $model Incoming Job Poster Key Task object. |
16 | 16 | * @return array |
17 | 17 | */ |
18 | - public function toApiArray(JobPosterKeyTask $model) |
|
18 | + public function toApiArray (JobPosterKeyTask $model) |
|
19 | 19 | { |
20 | - return array_merge($model->toArray(), $model->getTranslationsArray()); |
|
20 | + return array_merge ($model->toArray (), $model->getTranslationsArray ()); |
|
21 | 21 | } |
22 | 22 | |
23 | - public function indexByJob(JobPoster $jobPoster) |
|
23 | + public function indexByJob (JobPoster $jobPoster) |
|
24 | 24 | { |
25 | 25 | $toApiArray = array($this, 'toApiArray'); |
26 | - $taskArray = JobPosterKeyTask::where('job_poster_id', $jobPoster->id)->get()->map($toApiArray); |
|
27 | - return response()->json($taskArray); |
|
26 | + $taskArray = JobPosterKeyTask::where ('job_poster_id', $jobPoster->id)->get ()->map ($toApiArray); |
|
27 | + return response ()->json ($taskArray); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -34,39 +34,39 @@ discard block |
||
34 | 34 | * @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
35 | 35 | * @return \Illuminate\Http\Response |
36 | 36 | */ |
37 | - public function batchUpdate(BatchUpdateJobTask $request, JobPoster $jobPoster) |
|
37 | + public function batchUpdate (BatchUpdateJobTask $request, JobPoster $jobPoster) |
|
38 | 38 | { |
39 | 39 | $toApiArray = array($this, 'toApiArray'); |
40 | 40 | |
41 | - $newTasks = collect($request->validated()); // Collection of JobPosterKeyTasks. |
|
41 | + $newTasks = collect ($request->validated ()); // Collection of JobPosterKeyTasks. |
|
42 | 42 | $oldTasks = $jobPoster->job_poster_key_tasks; |
43 | 43 | |
44 | 44 | $savedNewTaskIds = []; |
45 | 45 | |
46 | 46 | // First, delete old tasks that weren't resubmitted, and update those that were. |
47 | 47 | foreach ($oldTasks as $task) { |
48 | - $newTask = $newTasks->firstWhere('id', $task['id']); |
|
48 | + $newTask = $newTasks->firstWhere ('id', $task['id']); |
|
49 | 49 | if ($newTask) { |
50 | 50 | $savedNewTaskIds[] = $newTask['id']; |
51 | - $task->fill(collect($newTask)->only(['en', 'fr'])->toArray()); |
|
52 | - $task->save(); |
|
51 | + $task->fill (collect ($newTask)->only (['en', 'fr'])->toArray ()); |
|
52 | + $task->save (); |
|
53 | 53 | } else { |
54 | - $task->delete(); |
|
54 | + $task->delete (); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Now, save any new tasks that remain. |
59 | 59 | foreach ($newTasks as $task) { |
60 | - if ($this->isUnsaved($task, $savedNewTaskIds)) { |
|
61 | - $jobPosterTask = new JobPosterKeyTask(); |
|
60 | + if ($this->isUnsaved ($task, $savedNewTaskIds)) { |
|
61 | + $jobPosterTask = new JobPosterKeyTask (); |
|
62 | 62 | $jobPosterTask->job_poster_id = $jobPoster->id; |
63 | - $jobPosterTask->fill(collect($task)->only(['en', 'fr'])->toArray()); |
|
64 | - $jobPosterTask->save(); |
|
63 | + $jobPosterTask->fill (collect ($task)->only (['en', 'fr'])->toArray ()); |
|
64 | + $jobPosterTask->save (); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - $taskArray = $jobPoster->fresh()->job_poster_key_tasks->map($toApiArray); |
|
69 | - return response()->json($taskArray); |
|
68 | + $taskArray = $jobPoster->fresh ()->job_poster_key_tasks->map ($toApiArray); |
|
69 | + return response ()->json ($taskArray); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param number[] $savedTaskIds Array of saved task IDs. |
77 | 77 | * @return boolean |
78 | 78 | */ |
79 | - private function isUnsaved($task, array $savedTaskIds): bool |
|
79 | + private function isUnsaved ($task, array $savedTaskIds): bool |
|
80 | 80 | { |
81 | - return !array_key_exists('id', $task) || !in_array($task['id'], $savedTaskIds); |
|
81 | + return !array_key_exists ('id', $task) || !in_array ($task['id'], $savedTaskIds); |
|
82 | 82 | } |
83 | 83 | } |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | * @param Criteria $model |
18 | 18 | * @return void |
19 | 19 | */ |
20 | - public function toApiArray(Criteria $model) |
|
20 | + public function toApiArray (Criteria $model) |
|
21 | 21 | { |
22 | - return array_merge($model->toArray(), $model->getTranslationsArray()); |
|
22 | + return array_merge ($model->toArray (), $model->getTranslationsArray ()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | * @param JobPoster $jobPoster |
29 | 29 | * @return \Illuminate\Http\Response |
30 | 30 | */ |
31 | - public function indexByJob(JobPoster $jobPoster) |
|
31 | + public function indexByJob (JobPoster $jobPoster) |
|
32 | 32 | { |
33 | 33 | $toApiArray = array($this, 'toApiArray'); |
34 | - $criteriaAray = Criteria::where('job_poster_id', $jobPoster->id)->get()->map($toApiArray); |
|
35 | - return response()->json($criteriaAray); |
|
34 | + $criteriaAray = Criteria::where ('job_poster_id', $jobPoster->id)->get ()->map ($toApiArray); |
|
35 | + return response ()->json ($criteriaAray); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -42,43 +42,43 @@ discard block |
||
42 | 42 | * @param JobPoster $jobPoster |
43 | 43 | * @return \Illuminate\Http\Response |
44 | 44 | */ |
45 | - public function batchUpdate(Request $request, JobPoster $jobPoster) |
|
45 | + public function batchUpdate (Request $request, JobPoster $jobPoster) |
|
46 | 46 | { |
47 | 47 | $toApiArray = array($this, 'toApiArray'); |
48 | 48 | |
49 | - $newCriteria = collect($request->input()); // TODO: switch to validated |
|
49 | + $newCriteria = collect ($request->input ()); // TODO: switch to validated |
|
50 | 50 | $oldCriteria = $jobPoster->criteria; |
51 | 51 | |
52 | 52 | $updatedIds = []; |
53 | 53 | |
54 | 54 | // First, delete old criteria that weren't resubmitted, and update those that were |
55 | 55 | foreach ($oldCriteria as $criteria) { |
56 | - $newData = $newCriteria->firstWhere('id', $criteria['id']); |
|
56 | + $newData = $newCriteria->firstWhere ('id', $criteria['id']); |
|
57 | 57 | if ($newData) { |
58 | 58 | $updatedIds[] = $criteria->id; |
59 | - $this->updateCriteria($criteria, $newData); |
|
59 | + $this->updateCriteria ($criteria, $newData); |
|
60 | 60 | } else { |
61 | - $this->deleteCriteria($criteria); |
|
61 | + $this->deleteCriteria ($criteria); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | 65 | $isUnsaved = function ($criteria, $savedIds): bool { |
66 | - return !array_key_exists('id', $criteria) || !in_array($criteria['id'], $savedIds); |
|
66 | + return !array_key_exists ('id', $criteria) || !in_array ($criteria['id'], $savedIds); |
|
67 | 67 | }; |
68 | 68 | |
69 | 69 | // Now, save any new criteria that remain |
70 | 70 | foreach ($newCriteria as $criteriaData) { |
71 | - if ($isUnsaved($criteriaData, $updatedIds)) { |
|
72 | - $criteria = new Criteria(); |
|
71 | + if ($isUnsaved ($criteriaData, $updatedIds)) { |
|
72 | + $criteria = new Criteria (); |
|
73 | 73 | $criteria->job_poster_id = $jobPoster->id; |
74 | - $fillableData = collect($criteriaData)->except(['id', 'job_poster_id'])->toArray(); |
|
75 | - $criteria->fill($fillableData); |
|
76 | - $this->createCriteria($criteria); |
|
74 | + $fillableData = collect ($criteriaData)->except (['id', 'job_poster_id'])->toArray (); |
|
75 | + $criteria->fill ($fillableData); |
|
76 | + $this->createCriteria ($criteria); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - $criteriaAray = Criteria::where('job_poster_id', $jobPoster->id)->get()->map($toApiArray); |
|
81 | - return response()->json($criteriaAray); |
|
80 | + $criteriaAray = Criteria::where ('job_poster_id', $jobPoster->id)->get ()->map ($toApiArray); |
|
81 | + return response ()->json ($criteriaAray); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | * @param Criteria $criteria |
88 | 88 | * @return void |
89 | 89 | */ |
90 | - protected function createCriteria(Criteria $criteria) |
|
90 | + protected function createCriteria (Criteria $criteria) |
|
91 | 91 | { |
92 | - $criteria->save(); |
|
92 | + $criteria->save (); |
|
93 | 93 | |
94 | - $notification = $this->makeAssessmentPlanNotification( |
|
94 | + $notification = $this->makeAssessmentPlanNotification ( |
|
95 | 95 | 'CREATE', |
96 | 96 | $criteria |
97 | 97 | ); |
98 | - $notification->save(); |
|
98 | + $notification->save (); |
|
99 | 99 | |
100 | 100 | return $criteria; |
101 | 101 | } |
@@ -107,25 +107,25 @@ discard block |
||
107 | 107 | * @param mixed[] $newData Updated version of the Critera. |
108 | 108 | * @return void |
109 | 109 | */ |
110 | - protected function updateCriteria(Criteria $oldCriteria, $newData): void |
|
110 | + protected function updateCriteria (Criteria $oldCriteria, $newData): void |
|
111 | 111 | { |
112 | 112 | // We only need to create a notification when the non-descriptive fields change |
113 | 113 | if ($oldCriteria->skill_level_id != $newData['skill_level_id'] |
114 | 114 | || $oldCriteria->skill_id != $newData['skill_id'] |
115 | 115 | ) { |
116 | - $notification = $this->makeAssessmentPlanNotification( |
|
116 | + $notification = $this->makeAssessmentPlanNotification ( |
|
117 | 117 | 'UPDATE', |
118 | 118 | $oldCriteria, |
119 | 119 | $newData['skill_id'], |
120 | 120 | $newData['skill_level_id'], |
121 | 121 | $newData['criteria_type_id'] |
122 | 122 | ); |
123 | - $notification->save(); |
|
123 | + $notification->save (); |
|
124 | 124 | } |
125 | 125 | // Get just the data that can be changed |
126 | - $fillableData = collect($newData)->except(['id', 'job_poster_id'])->toArray(); |
|
127 | - $oldCriteria->fill($fillableData); |
|
128 | - $oldCriteria->save(); |
|
126 | + $fillableData = collect ($newData)->except (['id', 'job_poster_id'])->toArray (); |
|
127 | + $oldCriteria->fill ($fillableData); |
|
128 | + $oldCriteria->save (); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | * @param \App\Models\Criteria $criteria Incoming Criteria. |
135 | 135 | * @return void |
136 | 136 | */ |
137 | - protected function deleteCriteria(Criteria $criteria): void |
|
137 | + protected function deleteCriteria (Criteria $criteria): void |
|
138 | 138 | { |
139 | - $notification = $notification = $this->makeAssessmentPlanNotification( |
|
139 | + $notification = $notification = $this->makeAssessmentPlanNotification ( |
|
140 | 140 | 'DELETE', |
141 | 141 | $criteria |
142 | 142 | ); |
143 | - $notification->save(); |
|
143 | + $notification->save (); |
|
144 | 144 | |
145 | 145 | // Delete assessments related to this criteria. |
146 | - Assessment::where('criterion_id', $criteria->id)->delete(); |
|
147 | - $criteria->delete(); |
|
146 | + Assessment::where ('criterion_id', $criteria->id)->delete (); |
|
147 | + $criteria->delete (); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | * @param integer|null $newCriteriaTypeId Only used for UPDATE type notifications. |
158 | 158 | * @return \App\Models\AssessmentPlanNotification |
159 | 159 | */ |
160 | - protected function makeAssessmentPlanNotification( |
|
160 | + protected function makeAssessmentPlanNotification ( |
|
161 | 161 | string $type, |
162 | 162 | Criteria $criteria, |
163 | 163 | $newSkillId = null, |
164 | 164 | $newSkillLevelId = null, |
165 | 165 | $newCriteriaTypeId = null |
166 | 166 | ) { |
167 | - $notification = new AssessmentPlanNotification(); |
|
167 | + $notification = new AssessmentPlanNotification (); |
|
168 | 168 | $notification->job_poster_id = $criteria->job_poster_id; |
169 | 169 | $notification->type = $type; |
170 | 170 | $notification->criteria_id = $criteria->id; |
@@ -12,23 +12,23 @@ |
||
12 | 12 | * |
13 | 13 | * @return mixed |
14 | 14 | */ |
15 | - public function index() |
|
15 | + public function index () |
|
16 | 16 | { |
17 | - $skills = Skill::with('classifications')->get(); |
|
17 | + $skills = Skill::with ('classifications')->get (); |
|
18 | 18 | $skillsArray = []; |
19 | 19 | // TODO: improve effiency of getting translations. |
20 | 20 | foreach ($skills as $skill) { |
21 | 21 | $translations = [ |
22 | 22 | 'en' => [ |
23 | - 'name' => $skill->getTranslation('name', 'en'), |
|
24 | - 'description' => $skill->getTranslation('description', 'en'), |
|
23 | + 'name' => $skill->getTranslation ('name', 'en'), |
|
24 | + 'description' => $skill->getTranslation ('description', 'en'), |
|
25 | 25 | ], |
26 | 26 | 'fr' => [ |
27 | - 'name' => $skill->getTranslation('name', 'fr'), |
|
28 | - 'description' => $skill->getTranslation('description', 'fr'), |
|
27 | + 'name' => $skill->getTranslation ('name', 'fr'), |
|
28 | + 'description' => $skill->getTranslation ('description', 'fr'), |
|
29 | 29 | ] |
30 | 30 | ]; |
31 | - $skillsArray[] = array_merge($skill->toArray(), $translations); |
|
31 | + $skillsArray[] = array_merge ($skill->toArray (), $translations); |
|
32 | 32 | } |
33 | 33 | return ['skills' => $skillsArray]; |
34 | 34 | } |
@@ -14,17 +14,17 @@ |
||
14 | 14 | * @param \App\Models\WorkExperience $workExperience Incoming Work Experience. |
15 | 15 | * @return \Illuminate\Http\Response |
16 | 16 | */ |
17 | - public function destroy(Request $request, WorkExperience $workExperience) |
|
17 | + public function destroy (Request $request, WorkExperience $workExperience) |
|
18 | 18 | { |
19 | - $this->authorize('delete', $workExperience); |
|
20 | - $workExperience->delete(); |
|
19 | + $this->authorize ('delete', $workExperience); |
|
20 | + $workExperience->delete (); |
|
21 | 21 | |
22 | - if ($request->ajax()) { |
|
22 | + if ($request->ajax ()) { |
|
23 | 23 | return [ |
24 | 24 | 'message' => 'Work Experience delete', |
25 | 25 | ]; |
26 | 26 | } |
27 | 27 | |
28 | - return back(); |
|
28 | + return back (); |
|
29 | 29 | } |
30 | 30 | } |
@@ -17,31 +17,31 @@ discard block |
||
17 | 17 | * @throws \InvalidArgumentException For missing $question. |
18 | 18 | * @return mixed |
19 | 19 | */ |
20 | - public function store(Request $request) |
|
20 | + public function store (Request $request) |
|
21 | 21 | { |
22 | - $this->authorize('create', RatingGuideQuestion::class); |
|
22 | + $this->authorize ('create', RatingGuideQuestion::class); |
|
23 | 23 | |
24 | - $job_poster_id = (int)$request->json('job_poster_id'); |
|
25 | - $assessment_type_id = (int)$request->json('assessment_type_id'); |
|
26 | - $question = $request->json('question'); |
|
24 | + $job_poster_id = (int) $request->json ('job_poster_id'); |
|
25 | + $assessment_type_id = (int) $request->json ('assessment_type_id'); |
|
26 | + $question = $request->json ('question'); |
|
27 | 27 | |
28 | - JobPoster::findOrFail($job_poster_id); |
|
29 | - AssessmentType::findOrFail($assessment_type_id); |
|
28 | + JobPoster::findOrFail ($job_poster_id); |
|
29 | + AssessmentType::findOrFail ($assessment_type_id); |
|
30 | 30 | |
31 | - $ratingGuideQuestion = new RatingGuideQuestion([ |
|
31 | + $ratingGuideQuestion = new RatingGuideQuestion ([ |
|
32 | 32 | 'job_poster_id' => $job_poster_id, |
33 | 33 | 'assessment_type_id' => $assessment_type_id, |
34 | 34 | 'question' => $question, |
35 | 35 | ]); |
36 | 36 | // Check that this user is allowed to create an Assessment for this criterion. |
37 | - $this->authorize('update', $ratingGuideQuestion); |
|
37 | + $this->authorize ('update', $ratingGuideQuestion); |
|
38 | 38 | |
39 | - $ratingGuideQuestion->save(); |
|
40 | - $ratingGuideQuestion->refresh(); |
|
39 | + $ratingGuideQuestion->save (); |
|
40 | + $ratingGuideQuestion->refresh (); |
|
41 | 41 | |
42 | 42 | return [ |
43 | 43 | 'success' => "Successfully created rating guide question $ratingGuideQuestion->id", |
44 | - 'rating_guide_question' => $ratingGuideQuestion->toArray(), |
|
44 | + 'rating_guide_question' => $ratingGuideQuestion->toArray (), |
|
45 | 45 | ]; |
46 | 46 | } |
47 | 47 | |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | * @param \App\Models\RatingGuideQuestion $ratingGuideQuestion Incoming object. |
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | - public function show(RatingGuideQuestion $ratingGuideQuestion) |
|
54 | + public function show (RatingGuideQuestion $ratingGuideQuestion) |
|
55 | 55 | { |
56 | - $this->authorize('view', $ratingGuideQuestion); |
|
57 | - $ratingGuideQuestion->load([ |
|
56 | + $this->authorize ('view', $ratingGuideQuestion); |
|
57 | + $ratingGuideQuestion->load ([ |
|
58 | 58 | 'job_poster', |
59 | 59 | 'assessment_type' |
60 | 60 | ]); |
61 | - return $ratingGuideQuestion->toArray(); |
|
61 | + return $ratingGuideQuestion->toArray (); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -69,25 +69,25 @@ discard block |
||
69 | 69 | * @throws \InvalidArgumentException For missing $question. |
70 | 70 | * @return mixed |
71 | 71 | */ |
72 | - public function update(Request $request, RatingGuideQuestion $ratingGuideQuestion) |
|
72 | + public function update (Request $request, RatingGuideQuestion $ratingGuideQuestion) |
|
73 | 73 | { |
74 | - $this->authorize('update', $ratingGuideQuestion); |
|
74 | + $this->authorize ('update', $ratingGuideQuestion); |
|
75 | 75 | |
76 | - $job_poster_id = (int)$request->json('job_poster_id'); |
|
77 | - $assessment_type_id = (int)$request->json('assessment_type_id'); |
|
78 | - $question = $request->json('question'); |
|
76 | + $job_poster_id = (int) $request->json ('job_poster_id'); |
|
77 | + $assessment_type_id = (int) $request->json ('assessment_type_id'); |
|
78 | + $question = $request->json ('question'); |
|
79 | 79 | |
80 | - JobPoster::findOrFail($job_poster_id); |
|
81 | - AssessmentType::findOrFail($assessment_type_id); |
|
80 | + JobPoster::findOrFail ($job_poster_id); |
|
81 | + AssessmentType::findOrFail ($assessment_type_id); |
|
82 | 82 | |
83 | 83 | $ratingGuideQuestion->job_poster_id = $job_poster_id; |
84 | 84 | $ratingGuideQuestion->assessment_type_id = $assessment_type_id; |
85 | 85 | $ratingGuideQuestion->question = $question; |
86 | - $ratingGuideQuestion->save(); |
|
86 | + $ratingGuideQuestion->save (); |
|
87 | 87 | |
88 | 88 | return [ |
89 | 89 | 'success' => "Successfully updated rating guide question $ratingGuideQuestion->id", |
90 | - 'rating_guide_question' => $ratingGuideQuestion->toArray(), |
|
90 | + 'rating_guide_question' => $ratingGuideQuestion->toArray (), |
|
91 | 91 | ]; |
92 | 92 | } |
93 | 93 | |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | * @param \App\Models\RatingGuideQuestion $ratingGuideQuestion Incoming object. |
98 | 98 | * @return mixed |
99 | 99 | */ |
100 | - public function destroy(RatingGuideQuestion $ratingGuideQuestion) |
|
100 | + public function destroy (RatingGuideQuestion $ratingGuideQuestion) |
|
101 | 101 | { |
102 | - $this->authorize('delete', $ratingGuideQuestion); |
|
103 | - $ratingGuideQuestion->delete(); |
|
102 | + $this->authorize ('delete', $ratingGuideQuestion); |
|
103 | + $ratingGuideQuestion->delete (); |
|
104 | 104 | |
105 | 105 | return [ |
106 | 106 | 'success' => "Successfully deleted rating guide question $ratingGuideQuestion->id" |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | { |
12 | 12 | use AuthorizesRequests, DispatchesJobs, ValidatesRequests; |
13 | 13 | |
14 | - public function getRelativeIds($input, $relativeType) |
|
14 | + public function getRelativeIds ($input, $relativeType) |
|
15 | 15 | { |
16 | 16 | $relativeIds = []; |
17 | 17 | if (isset($input['relatives'])) { |
@@ -25,30 +25,30 @@ discard block |
||
25 | 25 | return $relativeIds; |
26 | 26 | } |
27 | 27 | |
28 | - public function shiftFirstLevelArrayKeysToBottom(array $nestedArray) |
|
28 | + public function shiftFirstLevelArrayKeysToBottom (array $nestedArray) |
|
29 | 29 | { |
30 | - $expandedArray = $this->expandNestedArraysIntoKeyListAndValue($nestedArray); |
|
31 | - $rotatedArray = $this->rotateKeys($expandedArray, 1); |
|
32 | - $mergedArray = $this->mergeExpandedTrees($rotatedArray); |
|
30 | + $expandedArray = $this->expandNestedArraysIntoKeyListAndValue ($nestedArray); |
|
31 | + $rotatedArray = $this->rotateKeys ($expandedArray, 1); |
|
32 | + $mergedArray = $this->mergeExpandedTrees ($rotatedArray); |
|
33 | 33 | return $mergedArray; |
34 | 34 | } |
35 | 35 | |
36 | - protected function addKeyAsFinalIndex($finalKey, $array) |
|
36 | + protected function addKeyAsFinalIndex ($finalKey, $array) |
|
37 | 37 | { |
38 | - if (!is_array($array)) { |
|
38 | + if (!is_array ($array)) { |
|
39 | 39 | return [$finalKey => $array]; |
40 | 40 | } else { |
41 | 41 | $newArray = []; |
42 | 42 | foreach ($array as $key => $value) { |
43 | - $newArray[$key] = $this->addKeyAsFinalIndex($finalKey, $value); |
|
43 | + $newArray[$key] = $this->addKeyAsFinalIndex ($finalKey, $value); |
|
44 | 44 | } |
45 | 45 | return $newArray; |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - protected function expandNestedArraysIntoKeyListAndValue($nestedArray) |
|
49 | + protected function expandNestedArraysIntoKeyListAndValue ($nestedArray) |
|
50 | 50 | { |
51 | - if (!is_array($nestedArray)) { |
|
51 | + if (!is_array ($nestedArray)) { |
|
52 | 52 | $expandedArray = [ |
53 | 53 | [ |
54 | 54 | 'keys' => [], |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | } else { |
60 | 60 | $expandedArray = []; |
61 | 61 | foreach ($nestedArray as $key => $value) { |
62 | - $subArray = $this->expandNestedArraysIntoKeyListAndValue($value); |
|
62 | + $subArray = $this->expandNestedArraysIntoKeyListAndValue ($value); |
|
63 | 63 | foreach ($subArray as $item) { |
64 | - array_unshift($item['keys'], $key); |
|
64 | + array_unshift ($item['keys'], $key); |
|
65 | 65 | $expandedArray[] = $item; |
66 | 66 | } |
67 | 67 | } |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - protected function mergeExpandedTrees($expandedArray) |
|
72 | + protected function mergeExpandedTrees ($expandedArray) |
|
73 | 73 | { |
74 | 74 | $mergedArray = []; |
75 | 75 | foreach ($expandedArray as $item) { |
76 | 76 | $tail = &$mergedArray; |
77 | - $size = count($item['keys']); |
|
77 | + $size = count ($item['keys']); |
|
78 | 78 | $i = 0; |
79 | 79 | foreach ($item['keys'] as $key) { |
80 | 80 | $i = ($i + 1); |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | if ($i == ($size)) { |
83 | 83 | if (!isset($tail[$key])) { |
84 | 84 | $tail[$key] = $item['value']; |
85 | - } elseif (!is_array($tail[$key])) { |
|
85 | + } elseif (!is_array ($tail[$key])) { |
|
86 | 86 | $value = $tail[$key]; |
87 | 87 | $tail[$key] = [$value, $item['value']]; |
88 | 88 | } else { |
89 | - array_push($tail[$key], $item['value']); |
|
89 | + array_push ($tail[$key], $item['value']); |
|
90 | 90 | } |
91 | 91 | } else { |
92 | 92 | // If this is not the last key, it needs to contain an array. |
93 | 93 | if (!isset($tail[$key])) { |
94 | 94 | $tail[$key] = []; |
95 | - } elseif (!is_array($tail[$key])) { |
|
95 | + } elseif (!is_array ($tail[$key])) { |
|
96 | 96 | $value = $tail[$key]; |
97 | 97 | $tail[$key] = [$value]; |
98 | 98 | } |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | return $mergedArray; |
104 | 104 | } |
105 | 105 | |
106 | - protected function rotateKeys($expandedArray, $steps) |
|
106 | + protected function rotateKeys ($expandedArray, $steps) |
|
107 | 107 | { |
108 | 108 | $rotatedArray = []; |
109 | 109 | foreach ($expandedArray as $item) { |
110 | - for ($i=0; $i<$steps; $i++) { |
|
111 | - array_push($item['keys'], array_shift($item['keys'])); |
|
110 | + for ($i = 0; $i < $steps; $i++) { |
|
111 | + array_push ($item['keys'], array_shift ($item['keys'])); |
|
112 | 112 | } |
113 | 113 | $rotatedArray[] = $item; |
114 | 114 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param string[] $content The array being returned in response. |
122 | 122 | * @return \Illuminate\Http\Response |
123 | 123 | */ |
124 | - protected function formatAjaxResponse(array $content) |
|
124 | + protected function formatAjaxResponse (array $content) |
|
125 | 125 | { |
126 | - return response()->json($content); |
|
126 | + return response ()->json ($content); |
|
127 | 127 | } |
128 | 128 | } |