Completed
Push — docker_config ( 42a13c...d3c563 )
by Grant
12:41 queued 06:15
created

ApplicationByJobController::show()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 0
dl 0
loc 2
ccs 0
cts 1
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\Controllers;
4
5
use Barryvdh\Debugbar\Facade as Debugbar;
6
use Illuminate\Support\Facades\Lang;
7
use Illuminate\Http\Request;
8
use App\Models\Lookup\ApplicationStatus;
9
use App\Models\Lookup\VeteranStatus;
10
use App\Models\Lookup\PreferredLanguage;
11
use App\Models\Lookup\CitizenshipDeclaration;
12
use App\Models\Applicant;
13
use App\Models\JobPoster;
14
use App\Models\JobApplication;
15
use App\Models\JobApplicationAnswer;
16
use App\Models\SkillDeclaration;
17
use App\Models\Skill;
18
use App\Models\Lookup\SkillStatus;
19
use App\Models\Degree;
20
use App\Models\Lookup\CriteriaType;
21
use App\Models\Criteria;
22
use App\Models\Course;
23
use App\Models\WorkExperience;
24
use App\Services\Validation\ApplicationValidator;
25
use Illuminate\Support\Facades\Auth;
26
27
28
class ApplicationByJobController extends Controller
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ApplicationByJobController
Loading history...
29
{
30
    /**
31
     * Display a listing of the resource.
32
     *
33
     * @return \Illuminate\Http\Response
34
     */
35
    public function index()
36
    {
37
        //
38
    }
39
40
    protected function getApplicationFromJob(JobPoster $jobPoster) {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getApplicationFromJob()
Loading history...
41
        $application = JobApplication::where('applicant_id', Auth::user()->applicant->id)
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
42
            ->where('job_poster_id', $jobPoster->id)->first();
43
        if ($application == null) {
44
            $application = new JobApplication();
45
            $application->job_poster_id = $jobPoster->id;
46
            $application->applicant_id = Auth::user()->applicant->id;
47
            $application->application_status_id = ApplicationStatus::where('name', 'draft')->firstOrFail()->id;
48
            $application->save();
49
        }
50
        return $application;
51
    }
52
53
    /**
54
     * Show the form for editing Application basics for the specified job.
55
     *
56
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
57
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
58
     */
59
    public function edit_basics(JobPoster $jobPoster)
0 ignored issues
show
Coding Style introduced by
Public method name "ApplicationByJobController::edit_basics" is not in camel caps format
Loading history...
60
    {
61
62
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
63
64
        $application = $this->getApplicationFromJob($jobPoster);
65
66
        //Ensure user has permissions to view and update application
67
        $this->authorize('view', $application);
68
        $this->authorize('update', $application);
69
70
        return view('applicant/application_post_01', [
1 ignored issue
show
Bug Best Practice introduced by
The expression return view('applicant/a...pdate.1', $jobPoster))) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
71
72
            /* Application Template Data */
73
                "application_step" => 1,
74
                "application_template" => Lang::get("applicant/application_template"),
75
                "language_options" => PreferredLanguage::all(),
76
                "citizenship_options" => CitizenshipDeclaration::all(),
77
                "veteran_options" => VeteranStatus::all(),
78
                "preferred_language_template" => Lang::get('common/preferred_language'),
79
                "citizenship_declaration_template" => Lang::get('common/citizenship_declaration'),
80
                "veteran_status_template" => Lang::get('common/veteran_status'),
81
82
            /* Job Data */
83
                "job" => $jobPoster,
84
85
            /* Applicant Data */
86
                "applicant" => $applicant,
87
                "job_application" => $application,
88
89
            /* Submission */
90
                "form_submit_action" => route('job.application.update.1', $jobPoster)
0 ignored issues
show
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

90
                "form_submit_action" => route('job.application.update.1', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
91
92
        ]);
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...
93
94
    }
95
96
    /**
97
     * Show the form for editing Application Experience for the specified job.
98
     *
99
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
100
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
101
     */
102
    public function edit_experience(JobPoster $jobPoster)
0 ignored issues
show
Coding Style introduced by
Public method name "ApplicationByJobController::edit_experience" is not in camel caps format
Loading history...
103
    {
104
105
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
106
107
        $application = $this->getApplicationFromJob($jobPoster);
108
109
        //Ensure user has permissions to view and update application
110
        $this->authorize('view', $application);
111
        $this->authorize('update', $application);
112
113
        return view('applicant/application_post_02', [
1 ignored issue
show
Bug Best Practice introduced by
The expression return view('applicant/a...pdate.2', $jobPoster))) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
114
115
            /* Application Template Data */
116
                "application_step" => 2,
117
                "application_template" => Lang::get("applicant/application_template"),
118
119
            /* Job Data */
120
                "job" => $jobPoster,
121
122
            /* Applicant Data */
123
                "applicant" => $applicant,
124
                "job_application" => $application,
125
126
            /* Submission */
127
                "form_submit_action" => route('job.application.update.2', $jobPoster)
0 ignored issues
show
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

127
                "form_submit_action" => route('job.application.update.2', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
128
129
        ]);
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...
130
131
    }
132
133
    /**
134
     * Show the form for editing Application Essential Skills for the specified job.
135
     *
136
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
137
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
138
     */
139
    public function edit_essential_skills(JobPoster $jobPoster)
0 ignored issues
show
Coding Style introduced by
Public method name "ApplicationByJobController::edit_essential_skills" is not in camel caps format
Loading history...
140
    {
141
142
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
143
144
        $application = $this->getApplicationFromJob($jobPoster);
145
146
        //Ensure user has permissions to view and update application
147
        $this->authorize('view', $application);
148
        $this->authorize('update', $application);
149
150
        $criteria = [
151
            'essential' => $jobPoster->criteria->filter(function($value, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

151
            'essential' => $jobPoster->criteria->filter(function($value, /** @scrutinizer ignore-unused */ $key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
152
                return $value->criteria_type->name == 'essential';
153
            }),
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...
154
            'asset' => $jobPoster->criteria->filter(function($value, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

154
            'asset' => $jobPoster->criteria->filter(function($value, /** @scrutinizer ignore-unused */ $key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
155
                return $value->criteria_type->name == 'asset';
156
            }),
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...
157
        ];
158
159
        return view('applicant/application_post_03', [
1 ignored issue
show
Bug Best Practice introduced by
The expression return view('applicant/a...pdate.3', $jobPoster))) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
160
161
            /* Application Template Data */
162
                "application_step" => 3,
163
                "application_template" => Lang::get("applicant/application_template"),
164
165
            /* Job Data */
166
                "job" => $jobPoster,
167
168
            /* Skills Data */
169
                "skills" => Skill::all(),
170
                "skill_template" => Lang::get("common/skills"),
171
                "criteria" => $criteria,
172
173
            /* Applicant Data */
174
                "applicant" => $applicant,
175
                "job_application" => $application,
176
177
            /* Submission */
178
                "form_submit_action" => route('job.application.update.3', $jobPoster)
0 ignored issues
show
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

178
                "form_submit_action" => route('job.application.update.3', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
179
180
        ]);
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...
181
182
    }
183
184
    /**
185
     * Show the form for editing Application Asset Skills for the specified job.
186
     *
187
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
188
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
189
     */
190
    public function edit_asset_skills(JobPoster $jobPoster)
0 ignored issues
show
Coding Style introduced by
Public method name "ApplicationByJobController::edit_asset_skills" is not in camel caps format
Loading history...
191
    {
192
193
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
194
195
        $application = $this->getApplicationFromJob($jobPoster);
196
197
        //Ensure user has permissions to view and update application
198
        $this->authorize('view', $application);
199
        $this->authorize('update', $application);
200
201
        $criteria = [
202
            'essential' => $jobPoster->criteria->filter(function($value, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

202
            'essential' => $jobPoster->criteria->filter(function($value, /** @scrutinizer ignore-unused */ $key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
203
                return $value->criteria_type->name == 'essential';
204
            }),
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...
205
            'asset' => $jobPoster->criteria->filter(function($value, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

205
            'asset' => $jobPoster->criteria->filter(function($value, /** @scrutinizer ignore-unused */ $key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
206
                return $value->criteria_type->name == 'asset';
207
            }),
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...
208
        ];
209
210
        return view('applicant/application_post_04', [
1 ignored issue
show
Bug Best Practice introduced by
The expression return view('applicant/a...pdate.4', $jobPoster))) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
211
212
            /* Application Template Data */
213
                "application_step" => 4,
214
                "application_template" => Lang::get("applicant/application_template"),
215
216
            /* Job Data */
217
                "job" => $jobPoster,
218
219
            /* Skills Data */
220
                "skills" => Skill::all(),
221
                "skill_template" => Lang::get("common/skills"),
222
                "criteria" => $criteria,
223
224
            /* Applicant Data */
225
                "applicant" => $applicant,
226
                "job_application" => $application,
227
228
            /* Submission */
229
                "form_submit_action" => route('job.application.update.4', $jobPoster)
0 ignored issues
show
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

229
                "form_submit_action" => route('job.application.update.4', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
230
231
        ]);
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...
232
    }
233
234
    /**
235
     * Show the Application Preview for the application for the specified job.
236
     *
237
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
238
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
239
     */
240
    public function preview(JobPoster $jobPoster) {
241
242
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
243
244
        $application = $this->getApplicationFromJob($jobPoster);
245
246
        //TODO: Right now preview can't have the update gate, because we use the
247
            //  same view for viewing even after its been submitted. These should
248
            //  be seperate views, and then Preview can require the update permission.
249
        //Ensure user has permissions to view and update application
250
        $this->authorize('view', $application);
251
        //$this->authorize('update', $application);
252
253
        $criteria = [
254
            'essential' => $jobPoster->criteria->filter(function($value, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

254
            'essential' => $jobPoster->criteria->filter(function($value, /** @scrutinizer ignore-unused */ $key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
255
                return $value->criteria_type->name == 'essential';
256
            }),
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...
257
            'asset' => $jobPoster->criteria->filter(function($value, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

257
            'asset' => $jobPoster->criteria->filter(function($value, /** @scrutinizer ignore-unused */ $key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
258
                return $value->criteria_type->name == 'asset';
259
            }),
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...
260
        ];
261
262
        return view('applicant/application_post_05', [
1 ignored issue
show
Bug Best Practice introduced by
The expression return view('applicant/a....submit', $jobPoster))) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
263
264
            /* Application Template Data */
265
                "application_step" => 5,
266
                "application_template" => Lang::get("applicant/application_template"),
267
                "preferred_language_template" => Lang::get('common/preferred_language'),
268
                "citizenship_declaration_template" => Lang::get('common/citizenship_declaration'),
269
                "veteran_status_template" => Lang::get('common/veteran_status'),
270
271
            /* Job Data */
272
                "job" => $jobPoster,
273
274
            /* Skills Data */
275
                "skills" => Skill::all(),
276
                "skill_template" => Lang::get("common/skills"),
277
                "criteria" => $criteria,
278
279
            /* Applicant Data */
280
                "applicant" => $applicant,
281
                "job_application" => $application,
282
283
            /* Submission */
284
                "form_submit_action" => route('job.application.submit', $jobPoster)
0 ignored issues
show
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

284
                "form_submit_action" => route('job.application.submit', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
285
286
        ]);
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...
287
    }
288
289
    /**
290
     * Show the application submission information.
291
     *
292
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
293
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
294
     */
295
    public function complete(JobPoster $jobPoster) {
296
297
        /* Include Applicant Data */
298
299
            $applicant = Auth::user()->applicant;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
300
301
        /* Include Application Data */
302
303
            $application = $this->getApplicationFromJob($jobPoster);
304
305
            //Ensure user has permissions to view application
306
            $this->authorize('view', $application);
307
308
        /* Return the Completion View */
309
310
            return view('applicant/application_post_complete', [
1 ignored issue
show
Bug Best Practice introduced by
The expression return view('applicant/a...tion' => $application)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
311
312
                /* Application Template Data */
313
                    "application_template" => Lang::get("applicant/application_template"),
314
315
                /* Job Data */
316
                    "job" => $jobPoster,
317
318
                /* Applicant Data */
319
                    "applicant" => $applicant,
320
                    "job_application" => $application
321
322
            ]);
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...
323
324
    }
325
326
    /**
327
     * Update the Application Basics in storage for the specified job.
328
     *
329
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
330
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
331
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
332
     */
333
    public function update_basics(Request $request, JobPoster $jobPoster)
0 ignored issues
show
Coding Style introduced by
Public method name "ApplicationByJobController::update_basics" is not in camel caps format
Loading history...
334
    {
335
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Unused Code introduced by
The assignment to $applicant is dead and can be removed.
Loading history...
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
336
        $application = $this->getApplicationFromJob($jobPoster);
337
338
        //Ensure user has permissions to update this application
339
        $this->authorize('update', $application);
340
341
        $application->fill([
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...
342
            'citizenship_declaration_id' => $request->input('citizenship_declaration_id'),
343
            'veteran_status_id' => $request->input('veteran_status_id'),
344
            'preferred_language_id' => $request->input('preferred_language_id'),
345
        ]);
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...
346
        $application->save();
347
348
        $questions = $jobPoster->job_poster_questions;
349
        $questionsInput = $request->input('questions');
350
        foreach($questions as $question) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
351
            $answer = null;
352
            if (isset($questionsInput[$question->id])) {
353
                $answer = $questionsInput[$question->id];
354
            }
355
            $answerObj = $application->job_application_answers
356
                ->firstWhere('job_poster_question_id', $question->id);
357
            if ($answerObj == null) {
358
                $answerObj = new JobApplicationAnswer();
359
                $answerObj->job_poster_question_id = $question->id;
360
                $answerObj->job_application_id = $application->id;
361
            }
362
            $answerObj->answer = $answer;
363
            $answerObj->save();
364
        }
365
366
        //Redirect to correct page
367
        switch($request->input('submit')) {
368
            case 'save_and_quit':
369
            case 'previous':
370
                return redirect()->route('applications.index');
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route('applications.index') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
371
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
372
            case 'save_and_continue':
373
            case 'next':
374
                return redirect()->route('job.application.edit.2', $jobPoster);
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route...on.edit.2', $jobPoster) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of Illuminate\Routing\Redirector::route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

374
                return redirect()->route('job.application.edit.2', /** @scrutinizer ignore-type */ $jobPoster);
Loading history...
375
                break;
376
            default:
377
                return redirect()->back()->withInput();
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->back()->withInput() returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
378
                break;
379
        }
380
    }
381
382
    /**
383
     * Update the Application Basics in storage for the specified job.
384
     *
385
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
386
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
387
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
388
     */
389
    public function update_experience(Request $request, JobPoster $jobPoster)
0 ignored issues
show
Coding Style introduced by
Public method name "ApplicationByJobController::update_experience" is not in camel caps format
Loading history...
390
    {
391
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
392
        $application = $this->getApplicationFromJob($jobPoster);
393
394
        //Ensure user has permissions to update this application
395
        $this->authorize('update', $application);
396
397
        $degrees = $request->input('degrees');
398
399
        //Save new degrees
400
        if (isset($degrees['new'])) {
401
            foreach($degrees['new'] as $degreeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
402
                $degree = new Degree();
403
                $degree->applicant_id = $applicant->id;
404
                $degree->fill([
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...
405
                    'degree_type_id' => $degreeInput['degree_type_id'],
406
                    'area_of_study' => $degreeInput['area_of_study'],
407
                    'institution' => $degreeInput['institution'],
408
                    'thesis' => $degreeInput['thesis'],
409
                    'start_date' => $degreeInput['start_date'],
410
                    'end_date' => $degreeInput['end_date']
411
                ]);
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...
412
                $degree->save();
413
            }
414
        }
415
416
        //Update old degrees
417
        if (isset($degrees['old'])) {
418
            foreach($degrees['old'] as $id=>$degreeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
419
                //Ensure this degree belongs to this applicant
420
                $degree = $applicant->degrees->firstWhere('id', $id);
421
                if ($degree != null) {
422
                    $degree->fill([
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...
423
                        'degree_type_id' => $degreeInput['degree_type_id'],
424
                        'area_of_study' => $degreeInput['area_of_study'],
425
                        'institution' => $degreeInput['institution'],
426
                        'thesis' => $degreeInput['thesis'],
427
                        'start_date' => $degreeInput['start_date'],
428
                        'end_date' => $degreeInput['end_date']
429
                    ]);
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...
430
                    $degree->save();
431
                } else {
432
                    Debugbar::warning('Applicant '.$applicant->id.' attempted to update degree with invalid id '.$id);
433
                }
434
            }
435
        }
436
437
        $courses = $request->input('courses');
438
439
        //Save new courses
440
        if (isset($courses['new'])) {
441
            foreach($courses['new'] as $courseInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
442
                $course = new Course();
443
                $course->applicant_id = $applicant->id;
444
                $course->fill([
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...
445
                    'name' => $courseInput['name'],
446
                    'institution' => $courseInput['institution'],
447
                    'course_status_id' => $courseInput['course_status_id'],
448
                    'start_date' => $courseInput['start_date'],
449
                    'end_date' => $courseInput['end_date']
450
                ]);
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...
451
                $course->save();
452
            }
453
        }
454
455
        //Update old courses
456
        if (isset($courses['old'])) {
457
            foreach($courses['old'] as $id=>$courseInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
458
                //Ensure this course belongs to this applicant
459
                $course = $applicant->courses->firstWhere('id', $id);
460
                if ($course != null) {
461
                    $course->fill([
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...
462
                        'name' => $courseInput['name'],
463
                        'institution' => $courseInput['institution'],
464
                        'course_status_id' => $courseInput['course_status_id'],
465
                        'start_date' => $courseInput['start_date'],
466
                        'end_date' => $courseInput['end_date']
467
                    ]);
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...
468
                    $course->save();
469
                } else {
470
                    Debugbar::warning('Applicant '.$applicant->id.' attempted to update course with invalid id '.$id);
471
                }
472
            }
473
        }
474
475
        $work_experiences = $request->input('work_experiences');
476
477
        //Save new work_experiences
478
        if (isset($work_experiences['new'])) {
479
            foreach($work_experiences['new'] as $workExperienceInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
480
                $workExperience = new WorkExperience();
481
                $workExperience->applicant_id = $applicant->id;
482
                $workExperience->fill([
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...
483
                    'role' => $workExperienceInput['role'],
484
                    'company' => $workExperienceInput['company'],
485
                    'description' => $workExperienceInput['description'],
486
                    'start_date' => $workExperienceInput['start_date'],
487
                    'end_date' => $workExperienceInput['end_date']
488
                ]);
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...
489
                $workExperience->save();
490
            }
491
        }
492
493
        //Update old work_experiences
494
        if (isset($work_experiences['old'])) {
495
            foreach($work_experiences['old'] as $id=>$workExperienceInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
496
                //Ensure this work_experience belongs to this applicant
497
                $workExperience = $applicant->work_experiences->firstWhere('id', $id);
498
                if ($workExperience != null) {
499
                    $workExperience->fill([
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...
500
                        'role' => $workExperienceInput['role'],
501
                        'company' => $workExperienceInput['company'],
502
                        'description' => $workExperienceInput['description'],
503
                        'start_date' => $workExperienceInput['start_date'],
504
                        'end_date' => $workExperienceInput['end_date']
505
                    ]);
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...
506
                    $workExperience->save();
507
                } else {
508
                    Debugbar::warning('Applicant '.$applicant->id.' attempted to update work_experience with invalid id '.$id);
509
                }
510
            }
511
        }
512
513
        //Redirect to correct page
514
        switch($request->input('submit')) {
515
            case 'save_and_quit':
516
                return redirect()->route('applications.index');
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route('applications.index') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
517
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
518
            case 'save_and_continue':
519
            case 'next':
520
                return redirect()->route('job.application.edit.3', $jobPoster);
1 ignored issue
show
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of Illuminate\Routing\Redirector::route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

520
                return redirect()->route('job.application.edit.3', /** @scrutinizer ignore-type */ $jobPoster);
Loading history...
Bug Best Practice introduced by
The expression return redirect()->route...on.edit.3', $jobPoster) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
521
                break;
522
            case 'previous':
523
                return redirect()->route('job.application.edit.1', $jobPoster);
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route...on.edit.1', $jobPoster) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
524
                break;
525
            default:
526
                return redirect()->back()->withInput();
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->back()->withInput() returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
527
                break;
528
        }
529
    }
530
531
    /**
532
     * Update the Application Essential Skills in storage for the specified job.
533
     *
534
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
535
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
536
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
537
     */
538
    public function update_essential_skills(Request $request, JobPoster $jobPoster)
0 ignored issues
show
Coding Style introduced by
Public method name "ApplicationByJobController::update_essential_skills" is not in camel caps format
Loading history...
539
    {
540
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
541
        $application = $this->getApplicationFromJob($jobPoster);
542
543
        //Ensure user has permissions to update this application
544
        $this->authorize('update', $application);
545
546
        $skillDeclarations = $request->input('skill_declarations');
547
        $claimedStatusId = SkillStatus::where('name', 'claimed')->firstOrFail()->id;
548
549
        //Save new skill declarartions
550
        if (isset($skillDeclarations['new'])) {
551
            foreach($skillDeclarations['new'] as $skillType => $typeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
552
                foreach($typeInput as $criterion_id=>$skillDeclarationInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
553
                    $skillDeclaration = new SkillDeclaration();
554
                    $skillDeclaration->applicant_id = $applicant->id;
555
                    $skillDeclaration->skill_id = Criteria::find($criterion_id)->skill->id;
556
                    $skillDeclaration->skill_status_id = $claimedStatusId;
557
                    $skillDeclaration->fill([
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...
558
                        'description' => $skillDeclarationInput['description'],
559
                        'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null,
560
                    ]);
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...
561
                    $skillDeclaration->save();
562
563
                    $referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references');
564
                    $skillDeclaration->references()->sync($referenceIds);
565
566
                    $sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples');
567
                    $skillDeclaration->work_samples()->sync($sampleIds);
568
                }
569
            }
570
        }
571
572
        //Update old declarations
573
        if (isset($skillDeclarations['old'])) {
574
            foreach($skillDeclarations['old'] as $skillType => $typeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
575
                foreach($typeInput as $id=>$skillDeclarationInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
576
                    //Ensure this declaration belongs to this applicant
577
                    $skillDeclaration = $applicant->skill_declarations->firstWhere('id', $id);
578
                    if ($skillDeclaration != null) {
579
                        //skill_id and skill_status cannot be changed
580
                        $skillDeclaration->fill([
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...
581
                            'description' => $skillDeclarationInput['description'],
582
                            'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null,
583
                        ]);
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...
584
                        $skillDeclaration->save();
585
586
                        $referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references');
587
                        $skillDeclaration->references()->sync($referenceIds);
588
589
                        $sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples');
590
                        $skillDeclaration->work_samples()->sync($sampleIds);
591
                    } else {
592
                        Debugbar::warning('Applicant '.$applicant->id.' attempted to update skill declaration with invalid id '.$id);
593
                    }
594
                }
595
            }
596
        }
597
598
        //Redirect to correct page
599
        switch($request->input('submit')) {
600
            case 'save_and_quit':
601
                return redirect()->route('applications.index');
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route('applications.index') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
602
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
603
            case 'save_and_continue':
604
            case 'next':
605
                return redirect()->route('job.application.edit.4', $jobPoster);
1 ignored issue
show
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of Illuminate\Routing\Redirector::route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

605
                return redirect()->route('job.application.edit.4', /** @scrutinizer ignore-type */ $jobPoster);
Loading history...
Bug Best Practice introduced by
The expression return redirect()->route...on.edit.4', $jobPoster) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
606
                break;
607
            case 'previous':
608
                return redirect()->route('job.application.edit.2', $jobPoster);
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route...on.edit.2', $jobPoster) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
609
                break;
610
            default:
611
                return redirect()->back()->withInput();
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->back()->withInput() returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
612
                break;
613
        }
614
    }
615
616
    /**
617
     * Update the Application Asset Skills in storage for the specified job.
618
     *
619
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
620
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
621
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
622
     */
623
    public function update_asset_skills(Request $request, JobPoster $jobPoster)
0 ignored issues
show
Coding Style introduced by
Public method name "ApplicationByJobController::update_asset_skills" is not in camel caps format
Loading history...
624
    {
625
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
626
        $application = $this->getApplicationFromJob($jobPoster);
627
628
        //Ensure user has permissions to update this application
629
        $this->authorize('update', $application);
630
631
        $skillDeclarations = $request->input('skill_declarations');
632
        $claimedStatusId = SkillStatus::where('name', 'claimed')->firstOrFail()->id;
633
634
        //Save new skill declarartions
635
        if (isset($skillDeclarations['new'])) {
636
            foreach($skillDeclarations['new'] as $skillType => $typeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
637
                foreach($typeInput as $criterion_id=>$skillDeclarationInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
638
                    $skillDeclaration = new SkillDeclaration();
639
                    $skillDeclaration->applicant_id = $applicant->id;
640
                    $skillDeclaration->skill_id = Criteria::find($criterion_id)->skill->id;
641
                    $skillDeclaration->skill_status_id = $claimedStatusId;
642
                    $skillDeclaration->fill([
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...
643
                        'description' => $skillDeclarationInput['description'],
644
                        'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null,
645
                    ]);
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...
646
                    $skillDeclaration->save();
647
648
                    $referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references');
649
                    $skillDeclaration->references()->sync($referenceIds);
650
651
                    $sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples');
652
                    $skillDeclaration->work_samples()->sync($sampleIds);
653
                }
654
            }
655
        }
656
657
        //Update old declarations
658
        if (isset($skillDeclarations['old'])) {
659
            foreach($skillDeclarations['old'] as $skillType => $typeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
660
                foreach($typeInput as $id=>$skillDeclarationInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
661
                    //Ensure this declaration belongs to this applicant
662
                    $skillDeclaration = $applicant->skill_declarations->firstWhere('id', $id);
663
                    if ($skillDeclaration != null) {
664
                        //skill_id and skill_status cannot be changed
665
                        $skillDeclaration->fill([
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...
666
                            'description' => $skillDeclarationInput['description'],
667
                            'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null,
668
                        ]);
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...
669
                        $skillDeclaration->save();
670
671
                        $referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references');
672
                        $skillDeclaration->references()->sync($referenceIds);
673
674
                        $sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples');
675
                        $skillDeclaration->work_samples()->sync($sampleIds);
676
                    } else {
677
                        Debugbar::warning('Applicant '.$applicant->id.' attempted to update skill declaration with invalid id '.$id);
678
                    }
679
                }
680
            }
681
        }
682
683
        //Redirect to correct page
684
        switch($request->input('submit')) {
685
            case 'save_and_quit':
686
                return redirect()->route('applications.index');
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route('applications.index') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
687
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
688
            case 'save_and_continue':
689
            case 'next':
690
                return redirect()->route('job.application.edit.5', $jobPoster);
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route...on.edit.5', $jobPoster) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of Illuminate\Routing\Redirector::route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

690
                return redirect()->route('job.application.edit.5', /** @scrutinizer ignore-type */ $jobPoster);
Loading history...
691
                break;
692
            case 'previous':
693
                return redirect()->route('job.application.edit.3', $jobPoster);
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route...on.edit.3', $jobPoster) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
694
                break;
695
            default:
696
                return redirect()->back()->withInput();
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->back()->withInput() returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
697
                break;
698
        }
699
    }
700
701
    /**
702
     * Submit the Application for the specified job.
703
     *
704
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
705
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
706
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
707
     */
708
    public function submit(Request $request, JobPoster $jobPoster)
709
    {
710
        $applicant = Auth::user()->applicant;
0 ignored issues
show
Unused Code introduced by
The assignment to $applicant is dead and can be removed.
Loading history...
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
711
        $application = $this->getApplicationFromJob($jobPoster);
712
713
        //Ensure user has permissions to update this application
714
        $this->authorize('update', $application);
715
716
        //Only complete submission if submit button was pressed
717
        if ($request->input('submit') == "submit") {
718
719
            $request->validate([
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...
720
                'submission_signature' => [
721
                    'required',
722
                    'string',
723
                    'max:191',
724
                ],
725
                'submission_date' => [
726
                    'required',
727
                    'string',
728
                    'max:191',
729
               ]
730
           ]);
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...
731
732
           //Save any final info
733
           $application->fill([
0 ignored issues
show
Coding Style introduced by
Opening statement of multi-line function call not indented correctly; expected 8 spaces but found 11
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
734
               'submission_signature' => $request->input('submission_signature'),
735
               'submission_date' => $request->input('submission_date'),
736
           ]);
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...
737
738
            $validator = new ApplicationValidator();
739
            $validator->validate($application);
740
741
            //Change status to 'submitted'
742
            $application->application_status_id = ApplicationStatus::where('name', 'submitted')->firstOrFail()->id;
743
        }
744
745
        $application->save();
746
747
        //Redirect to correct page
748
        switch($request->input('submit')) {
749
            case 'save_and_quit':
750
                return redirect()->route('applications.index');
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route('applications.index') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
751
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
752
            case 'submit':
753
                return redirect()->route('job.application.complete', $jobPoster);
1 ignored issue
show
Bug introduced by
$jobPoster of type App\Models\JobPoster is incompatible with the type array expected by parameter $parameters of Illuminate\Routing\Redirector::route(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

753
                return redirect()->route('job.application.complete', /** @scrutinizer ignore-type */ $jobPoster);
Loading history...
Bug Best Practice introduced by
The expression return redirect()->route....complete', $jobPoster) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
754
                break;
755
            case 'previous':
756
                return redirect()->route('job.application.edit.4', $jobPoster);
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->route...on.edit.4', $jobPoster) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
757
                break;
758
            default:
759
                return redirect()->back()->withInput();
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->back()->withInput() returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
760
                break;
761
        }
762
    }
763
}
764