Completed
Pull Request — dev (#355)
by Josh
13:53 queued 07:04
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
    /**
41
     * Display the Application for the specified job
42
     *
43
     * @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...
44
     * @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...
45
     */
46
    public function show(JobPoster $jobPoster)
0 ignored issues
show
Unused Code introduced by
The parameter $jobPoster 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

46
    public function show(/** @scrutinizer ignore-unused */ JobPoster $jobPoster)

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...
47
    {
48
        //
49
    }
50
51
    protected function getApplicationFromJob(JobPoster $jobPoster) {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getApplicationFromJob()
Loading history...
52
        $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...
53
            ->where('job_poster_id', $jobPoster->id)->first();
54
        if ($application == null) {
55
            $application = new JobApplication();
56
            $application->job_poster_id = $jobPoster->id;
57
            $application->applicant_id = Auth::user()->applicant->id;
58
            $application->application_status_id = ApplicationStatus::where('name', 'draft')->firstOrFail()->id;
59
            $application->save();
60
        }
61
        return $application;
62
    }
63
64
    /**
65
     * Show the form for editing Application basics for the specified job.
66
     *
67
     * @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...
68
     * @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...
69
     */
70
    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...
71
    {
72
73
        $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...
74
75
        $application = $this->getApplicationFromJob($jobPoster);
76
77
        //This is an alternative way of using policies instead of via middleware
78
        if (!Auth::user()->can('view', $application) ||
79
            !Auth::user()->can('update', $application)) {
0 ignored issues
show
Coding Style introduced by
Each line in a multi-line IF statement must begin with a boolean operator
Loading history...
Coding Style introduced by
Closing parenthesis of a multi-line IF statement must be on a new line
Loading history...
80
            abort(401);
81
        }
82
83
        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...
84
85
            /* Application Template Data */
86
                "application_step" => 1,
87
                "application_template" => Lang::get("applicant/application_template"),
88
                "language_options" => PreferredLanguage::all(),
89
                "citizenship_options" => CitizenshipDeclaration::all(),
90
                "veteran_options" => VeteranStatus::all(),
91
                "preferred_language_template" => Lang::get('common/preferred_language'),
92
                "citizenship_declaration_template" => Lang::get('common/citizenship_declaration'),
93
                "veteran_status_template" => Lang::get('common/veteran_status'),
94
95
            /* Job Data */
96
                "job" => $jobPoster,
97
98
            /* Applicant Data */
99
                "applicant" => $applicant,
100
                "job_application" => $application,
101
102
            /* Submission */
103
                "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

103
                "form_submit_action" => route('job.application.update.1', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
104
105
        ]);
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...
106
107
    }
108
109
    /**
110
     * Show the form for editing Application Experience for the specified job.
111
     *
112
     * @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...
113
     * @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...
114
     */
115
    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...
116
    {
117
118
        $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...
119
120
        $application = $this->getApplicationFromJob($jobPoster);
121
122
        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...
123
124
            /* Application Template Data */
125
                "application_step" => 2,
126
                "application_template" => Lang::get("applicant/application_template"),
127
128
            /* Job Data */
129
                "job" => $jobPoster,
130
131
            /* Applicant Data */
132
                "applicant" => $applicant,
133
                "job_application" => $application,
134
135
            /* Submission */
136
                "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

136
                "form_submit_action" => route('job.application.update.2', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
137
138
        ]);
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...
139
140
    }
141
142
    /**
143
     * Show the form for editing Application Essential Skills for the specified job.
144
     *
145
     * @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...
146
     * @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...
147
     */
148
    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...
149
    {
150
151
        $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...
152
153
        $application = $this->getApplicationFromJob($jobPoster);
154
155
        $criteria = [
156
            '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

156
            '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...
157
                return $value->criteria_type->name == 'essential';
158
            }),
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...
159
            '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

159
            '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...
160
                return $value->criteria_type->name == 'asset';
161
            }),
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...
162
        ];
163
164
        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...
165
            
166
            /* Application Template Data */
167
                "application_step" => 3,
168
                "application_template" => Lang::get("applicant/application_template"),
169
170
            /* Job Data */
171
                "job" => $jobPoster,
172
173
            /* Skills Data */
174
                "skills" => Skill::all(),
175
                "skill_template" => Lang::get("common/skills"),
176
                "criteria" => $criteria,
177
178
            /* Applicant Data */
179
                "applicant" => $applicant,
180
                "job_application" => $application,
181
182
            /* Submission */
183
                "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

183
                "form_submit_action" => route('job.application.update.3', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
184
185
        ]);
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...
186
187
    }
188
189
    /**
190
     * Show the form for editing Application Asset Skills for the specified job.
191
     *
192
     * @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...
193
     * @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...
194
     */
195
    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...
196
    {
197
198
        $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...
199
200
        $application = $this->getApplicationFromJob($jobPoster);
201
202
        $criteria = [
203
            '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

203
            '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...
204
                return $value->criteria_type->name == 'essential';
205
            }),
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...
206
            '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

206
            '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...
207
                return $value->criteria_type->name == 'asset';
208
            }),
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...
209
        ];
210
211
        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...
212
213
            /* Application Template Data */
214
                "application_step" => 4,
215
                "application_template" => Lang::get("applicant/application_template"),
216
217
            /* Job Data */
218
                "job" => $jobPoster,
219
220
            /* Skills Data */
221
                "skills" => Skill::all(),
222
                "skill_template" => Lang::get("common/skills"),
223
                "criteria" => $criteria,
224
225
            /* Applicant Data */
226
                "applicant" => $applicant,
227
                "job_application" => $application,
228
229
            /* Submission */
230
                "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

230
                "form_submit_action" => route('job.application.update.4', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
231
232
        ]);
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...
233
    }
234
235
    /**
236
     * Show the Application Preview for the application for the specified job.
237
     *
238
     * @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...
239
     * @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...
240
     */
241
    public function preview(JobPoster $jobPoster) {
242
243
        $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...
244
245
        $application = $this->getApplicationFromJob($jobPoster);
246
247
        $criteria = [
248
            '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

248
            '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...
249
                return $value->criteria_type->name == 'essential';
250
            }),
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...
251
            '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

251
            '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...
252
                return $value->criteria_type->name == 'asset';
253
            }),
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...
254
        ];
255
256
        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...
257
258
            /* Application Template Data */
259
                "application_step" => 5,
260
                "application_template" => Lang::get("applicant/application_template"),
261
                "preferred_language_template" => Lang::get('common/preferred_language'),
262
                "citizenship_declaration_template" => Lang::get('common/citizenship_declaration'),
263
                "veteran_status_template" => Lang::get('common/veteran_status'),
264
265
            /* Job Data */
266
                "job" => $jobPoster,
267
268
            /* Skills Data */
269
                "skills" => Skill::all(),
270
                "skill_template" => Lang::get("common/skills"),
271
                "criteria" => $criteria,
272
273
            /* Applicant Data */
274
                "applicant" => $applicant,
275
                "job_application" => $application,
276
277
            /* Submission */
278
                "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

278
                "form_submit_action" => route('job.application.submit', /** @scrutinizer ignore-type */ $jobPoster)
Loading history...
279
280
        ]);
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...
281
    }
282
283
    /**
284
     * Show the application submission information.
285
     *
286
     * @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...
287
     * @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...
288
     */
289
    public function complete(JobPoster $jobPoster) {
290
291
        /* Include Applicant Data */
292
293
            $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...
294
295
        /* Include Application Data */
296
297
            $application = $this->getApplicationFromJob($jobPoster);
298
299
        /* Return the Completion View */
300
301
            return view('applicant/application_post_complete', [
1 ignored issue
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
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...
302
303
                /* Application Template Data */
304
                    "application_template" => Lang::get("applicant/application_template"),
305
306
                /* Job Data */
307
                    "job" => $jobPoster,
308
309
                /* Applicant Data */
310
                    "applicant" => $applicant,
311
                    "job_application" => $application
312
313
            ]);
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...
314
315
    }
316
317
    /**
318
     * Update the Application Basics in storage for the specified job.
319
     *
320
     * @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...
321
     * @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...
322
     * @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...
323
     */
324
    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...
325
    {
326
        $input = $request->input();
327
        $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...
328
        $application = $this->getApplicationFromJob($jobPoster);
329
330
        $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...
331
            'citizenship_declaration_id' => $input['citizenship_declaration_id'],
332
            'veteran_status_id' => $input['veteran_status_id'],
333
            'preferred_language_id' => $input['preferred_language_id'],
334
        ]);
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...
335
        $application->save();
336
337
        $questions = $jobPoster->job_poster_questions;
338
        foreach($questions as $question) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
339
            $answer = null;
340
            if (isset($input['questions']) &&
341
                isset($input['questions'][$question->id])) {
0 ignored issues
show
Coding Style introduced by
Each line in a multi-line IF statement must begin with a boolean operator
Loading history...
Coding Style introduced by
Closing parenthesis of a multi-line IF statement must be on a new line
Loading history...
342
                $answer = $input['questions'][$question->id];
343
            }
344
            $answerObj = $application->job_application_answers
345
                ->firstWhere('job_poster_question_id', $question->id);
346
            if ($answerObj == null) {
347
                $answerObj = new JobApplicationAnswer();
348
                $answerObj->job_poster_question_id = $question->id;
349
                $answerObj->job_application_id = $application->id;
350
            }
351
            $answerObj->answer = $answer;
352
            $answerObj->save();
353
        }
354
355
        return redirect( route('job.application.edit.2', $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 route(). ( Ignorable by Annotation )

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

355
        return redirect( route('job.application.edit.2', /** @scrutinizer ignore-type */ $jobPoster));
Loading history...
Bug Best Practice introduced by
The expression return redirect(route('j...n.edit.2', $jobPoster)) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
356
    }
357
358
    /**
359
     * Update the Application Basics in storage for the specified job.
360
     *
361
     * @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...
362
     * @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...
363
     * @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...
364
     */
365
    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...
366
    {
367
        $input = $request->input();
368
        $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...
369
        $application = $this->getApplicationFromJob($jobPoster);
0 ignored issues
show
Unused Code introduced by
The assignment to $application is dead and can be removed.
Loading history...
370
371
        //TODO: save stuff to application
372
373
        //TODO: Note from Tristan: I did test this function, and it works as I expect,
374
        //TODO:     saving new/updated degrees, courses and work experiences
375
        //TODO:     to the profile.
376
        $degrees = $input['degrees'];
377
378
        //Save new degrees
379
        if (isset($degrees['new'])) {
380
            foreach($degrees['new'] as $degreeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
381
                $degree = new Degree();
382
                $degree->applicant_id = $applicant->id;
383
                $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...
384
                    'degree_type_id' => $degreeInput['degree_type_id'],
385
                    'area_of_study' => $degreeInput['area_of_study'],
386
                    'institution' => $degreeInput['institution'],
387
                    'thesis' => $degreeInput['thesis'],
388
                    'start_date' => $degreeInput['start_date'],
389
                    'end_date' => $degreeInput['end_date']
390
                ]);
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...
391
                $degree->save();
392
            }
393
        }
394
395
        //Update old degrees
396
        if (isset($degrees['old'])) {
397
            foreach($degrees['old'] as $id=>$degreeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
398
                //Ensure this degree belongs to this applicant
399
                $degree = $applicant->degrees->firstWhere('id', $id);
400
                if ($degree != null) {
401
                    $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...
402
                        'degree_type_id' => $degreeInput['degree_type_id'],
403
                        'area_of_study' => $degreeInput['area_of_study'],
404
                        'institution' => $degreeInput['institution'],
405
                        'thesis' => $degreeInput['thesis'],
406
                        'start_date' => $degreeInput['start_date'],
407
                        'end_date' => $degreeInput['end_date']
408
                    ]);
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...
409
                    $degree->save();
410
                } else {
411
                    Debugbar::warning('Applicant '.$applicant->id.' attempted to update degree with invalid id '.$id);
412
                }
413
            }
414
        }
415
416
        $courses = $input['courses'];
417
418
        //Save new courses
419
        if (isset($courses['new'])) {
420
            foreach($courses['new'] as $courseInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
421
                $course = new Course();
422
                $course->applicant_id = $applicant->id;
423
                $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...
424
                    'name' => $courseInput['name'],
425
                    'institution' => $courseInput['institution'],
426
                    'course_status_id' => $courseInput['course_status_id'],
427
                    'start_date' => $courseInput['start_date'],
428
                    'end_date' => $courseInput['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
                $course->save();
431
            }
432
        }
433
434
        //Update old courses
435
        if (isset($courses['old'])) {
436
            foreach($courses['old'] as $id=>$courseInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
437
                //Ensure this course belongs to this applicant
438
                $course = $applicant->courses->firstWhere('id', $id);
439
                if ($course != null) {
440
                    $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...
441
                        'name' => $courseInput['name'],
442
                        'institution' => $courseInput['institution'],
443
                        'course_status_id' => $courseInput['course_status_id'],
444
                        'start_date' => $courseInput['start_date'],
445
                        'end_date' => $courseInput['end_date']
446
                    ]);
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...
447
                    $course->save();
448
                } else {
449
                    Debugbar::warning('Applicant '.$applicant->id.' attempted to update course with invalid id '.$id);
450
                }
451
            }
452
        }
453
454
        $work_experiences = $input['work_experiences'] ;
455
456
        //Save new work_experiences
457
        if (isset($work_experiences['new'])) {
458
            foreach($work_experiences['new'] as $workExperienceInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
459
                $workExperience = new WorkExperience();
460
                $workExperience->applicant_id = $applicant->id;
461
                $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...
462
                    'role' => $workExperienceInput['role'],
463
                    'company' => $workExperienceInput['company'],
464
                    'description' => $workExperienceInput['description'],
465
                    'start_date' => $workExperienceInput['start_date'],
466
                    'end_date' => $workExperienceInput['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
                $workExperience->save();
469
            }
470
        }
471
472
        //Update old work_experiences
473
        if (isset($work_experiences['old'])) {
474
            foreach($work_experiences['old'] as $id=>$workExperienceInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
475
                //Ensure this work_experience belongs to this applicant
476
                $workExperience = $applicant->work_experiences->firstWhere('id', $id);
477
                if ($workExperience != null) {
478
                    $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...
479
                        'role' => $workExperienceInput['role'],
480
                        'company' => $workExperienceInput['company'],
481
                        'description' => $workExperienceInput['description'],
482
                        'start_date' => $workExperienceInput['start_date'],
483
                        'end_date' => $workExperienceInput['end_date']
484
                    ]);
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...
485
                    $workExperience->save();
486
                } else {
487
                    Debugbar::warning('Applicant '.$applicant->id.' attempted to update work_experience with invalid id '.$id);
488
                }
489
            }
490
        }
491
492
        return redirect( route('job.application.edit.3', $jobPoster));
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect(route('j...n.edit.3', $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 route(). ( Ignorable by Annotation )

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

492
        return redirect( route('job.application.edit.3', /** @scrutinizer ignore-type */ $jobPoster));
Loading history...
493
    }
494
495
    /**
496
     * Update the Application Essential Skills in storage for the specified job.
497
     *
498
     * @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...
499
     * @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...
500
     * @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...
501
     */
502
    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...
503
    {
504
        $input = $request->input();
505
        $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...
506
        $application = $this->getApplicationFromJob($jobPoster);
0 ignored issues
show
Unused Code introduced by
The assignment to $application is dead and can be removed.
Loading history...
507
508
        //TODO: save stuff to application
509
510
        //TODO: Note from Tristan: I haven't tested this. This was copied from the SkillsController.
511
        //TODO: But for now, if we're just updating the Applicant's Profile through this page,
512
        //TODO: then this same code, or something very close, should work.
513
514
        $skillDeclarations = $input['skill_declarations'];
515
        $claimedStatusId = SkillStatus::where('name', 'claimed')->firstOrFail()->id;
516
517
        //Save new skill declarartions
518
        if (isset($skillDeclarations['new'])) {
519
            foreach($skillDeclarations['new'] as $skillType => $typeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
520
                foreach($typeInput as $criterion_id=>$skillDeclarationInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
521
                    $skillDeclaration = new SkillDeclaration();
522
                    $skillDeclaration->applicant_id = $applicant->id;
523
                    $skillDeclaration->skill_id = Criteria::find($criterion_id)->skill->id;
524
                    $skillDeclaration->skill_status_id = $claimedStatusId;
525
                    $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...
526
                        'description' => $skillDeclarationInput['description'],
527
                        'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null,
528
                    ]);
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...
529
                    $skillDeclaration->save();
530
531
                    $referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references');
532
                    $skillDeclaration->references()->sync($referenceIds);
533
534
                    $sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples');
535
                    $skillDeclaration->work_samples()->sync($sampleIds);
536
                }
537
            }
538
        }
539
540
        //Update old declarations
541
        if (isset($skillDeclarations['old'])) {
542
            foreach($skillDeclarations['old'] as $skillType => $typeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
543
                foreach($typeInput as $id=>$skillDeclarationInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
544
                    //Ensure this declaration belongs to this applicant
545
                    $skillDeclaration = $applicant->skill_declarations->firstWhere('id', $id);
546
                    if ($skillDeclaration != null) {
547
                        //skill_id and skill_status cannot be changed
548
                        $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...
549
                            'description' => $skillDeclarationInput['description'],
550
                            'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null,
551
                        ]);
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...
552
                        $skillDeclaration->save();
553
554
                        $referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references');
555
                        $skillDeclaration->references()->sync($referenceIds);
556
557
                        $sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples');
558
                        $skillDeclaration->work_samples()->sync($sampleIds);
559
                    } else {
560
                        Debugbar::warning('Applicant '.$applicant->id.' attempted to update skill declaration with invalid id '.$id);
561
                    }
562
                }
563
            }
564
        }
565
566
        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 route(). ( Ignorable by Annotation )

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

566
        return redirect( route('job.application.edit.4', /** @scrutinizer ignore-type */ $jobPoster));
Loading history...
Bug Best Practice introduced by
The expression return redirect(route('j...n.edit.4', $jobPoster)) returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
567
    }
568
569
    /**
570
     * Update the Application Asset Skills in storage for the specified job.
571
     *
572
     * @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...
573
     * @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...
574
     * @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...
575
     */
576
    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...
577
    {
578
        $input = $request->input();
579
        $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...
580
        $application = $this->getApplicationFromJob($jobPoster);
0 ignored issues
show
Unused Code introduced by
The assignment to $application is dead and can be removed.
Loading history...
581
582
        //TODO: save stuff to application
583
584
        //TODO: Note from Tristan: I haven't tested this. This was copied from the SkillsController.
585
        //TODO: But for now, if we're just updating the Applicant's Profile through this page,
586
        //TODO: then this same code, or something very close, should work.
587
588
        $skillDeclarations = $input['skill_declarations'];
589
        $claimedStatusId = SkillStatus::where('name', 'claimed')->firstOrFail()->id;
590
591
        //Save new skill declarartions
592
        if (isset($skillDeclarations['new'])) {
593
            foreach($skillDeclarations['new'] as $skillType => $typeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
594
                foreach($typeInput as $criterion_id=>$skillDeclarationInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
595
                    $skillDeclaration = new SkillDeclaration();
596
                    $skillDeclaration->applicant_id = $applicant->id;
597
                    $skillDeclaration->skill_id = Criteria::find($criterion_id)->skill->id;
598
                    $skillDeclaration->skill_status_id = $claimedStatusId;
599
                    $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...
600
                        'description' => $skillDeclarationInput['description'],
601
                        'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null,
602
                    ]);
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...
603
                    $skillDeclaration->save();
604
605
                    $referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references');
606
                    $skillDeclaration->references()->sync($referenceIds);
607
608
                    $sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples');
609
                    $skillDeclaration->work_samples()->sync($sampleIds);
610
                }
611
            }
612
        }
613
614
        //Update old declarations
615
        if (isset($skillDeclarations['old'])) {
616
            foreach($skillDeclarations['old'] as $skillType => $typeInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
617
                foreach($typeInput as $id=>$skillDeclarationInput) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
618
                    //Ensure this declaration belongs to this applicant
619
                    $skillDeclaration = $applicant->skill_declarations->firstWhere('id', $id);
620
                    if ($skillDeclaration != null) {
621
                        //skill_id and skill_status cannot be changed
622
                        $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...
623
                            'description' => $skillDeclarationInput['description'],
624
                            'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null,
625
                        ]);
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...
626
                        $skillDeclaration->save();
627
628
                        $referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references');
629
                        $skillDeclaration->references()->sync($referenceIds);
630
631
                        $sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples');
632
                        $skillDeclaration->work_samples()->sync($sampleIds);
633
                    } else {
634
                        Debugbar::warning('Applicant '.$applicant->id.' attempted to update skill declaration with invalid id '.$id);
635
                    }
636
                }
637
            }
638
        }
639
640
        return redirect( route('job.application.edit.5', $jobPoster));
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect(route('j...n.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 route(). ( Ignorable by Annotation )

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

640
        return redirect( route('job.application.edit.5', /** @scrutinizer ignore-type */ $jobPoster));
Loading history...
641
    }
642
643
    /**
644
     * Submit the Application for the specified job.
645
     *
646
     * @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...
647
     * @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...
648
     * @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...
649
     */
650
    public function submit(Request $request, JobPoster $jobPoster)
651
    {
652
        $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...
653
            'submission_signature' => [
654
                'required',
655
                'string',
656
                'max:191',
657
            ],
658
            'submission_date' => [
659
                'required',
660
                'string',
661
                'max:191',
662
           ]
663
       ]);
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...
664
665
        $input = $request->input();
666
        $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...
Unused Code introduced by
The assignment to $applicant is dead and can be removed.
Loading history...
667
        $application = $this->getApplicationFromJob($jobPoster);
668
669
        //Save any final info
670
        $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...
671
            'submission_signature' => $input['submission_signature'],
672
            'submission_date' => $input['submission_date'],
673
        ]);
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...
674
675
        //TODO: Check that application is valid and complete
676
        $validator = new ApplicationValidator();
677
        $validator->validate($application);
678
679
        //Change status to 'submitted'
680
        $application->application_status_id = ApplicationStatus::where('name', 'submitted')->firstOrFail()->id;
681
682
        $application->save();
683
684
        return redirect( route('job.application.complete', $jobPoster));
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect(route('j...complete', $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 route(). ( Ignorable by Annotation )

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

684
        return redirect( route('job.application.complete', /** @scrutinizer ignore-type */ $jobPoster));
Loading history...
685
    }
686
}
687