Passed
Push — task/all-applications-to-pdf ( 852a46...40d2cb )
by Tristan
13:25
created

UpdateJobPoster::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 29
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 31
ccs 29
cts 29
cp 1
rs 9.456
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Support\Facades\Config;
7
use App\Services\Validation\Rules\ValidIdRule;
8
use App\Models\Lookup\Department;
9
use App\Models\Lookup\Province;
10
use App\Models\Lookup\SecurityClearance;
11
use App\Models\Lookup\LanguageRequirement;
12
13
class UpdateJobPoster extends FormRequest
14
{
15
    /**
16
     * Determine if the user is authorized to make this request.
17
     *
18
     * @return bool
1 ignored issue
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
19
     */
20 2
    public function authorize()
0 ignored issues
show
introduced by
Method \App\Http\Requests\UpdateJobPoster::authorize() does not have return type hint for its return value but it should be possible to add it based on @return annotation "bool".
Loading history...
21
    {
22 2
        return true;
23
    }
24
25
    /**
26
     * Get the validation rules that apply to the request.
27
     *
28
     * @return array
0 ignored issues
show
introduced by
@return annotation of method \App\Http\Requests\UpdateJobPoster::rules() does not specify type hint for items of its traversable return value.
Loading history...
29
     */
30 2
    public function rules()
0 ignored issues
show
introduced by
Method \App\Http\Requests\UpdateJobPoster::rules() does not have return type hint for its return value but it should be possible to add it based on @return annotation "array".
Loading history...
31
    {
32 2
        $dateFormat = Config::get('app.api_datetime_format');
33 2
        $dateFormatRule = "date_format:$dateFormat";
34
        return [
35 2
            'term_qty' => 'required|numeric',
36 2
            'open_date_time' =>['required', $dateFormatRule],
37 2
            'close_date_time' => ['required', $dateFormatRule],
38 2
            'start_date_time' =>['required', $dateFormatRule],
39 2
            'department_id' => ['required', new ValidIdRule(Department::class)],
40 2
            'province_id' => ['required', new ValidIdRule(Province::class)],
41 2
            'security_clearance_id' => ['required', new ValidIdRule(SecurityClearance::class)],
42 2
            'language_requirement_id' => ['required', new ValidIdRule(LanguageRequirement::class)],
43 2
            'salary_min' => 'required|numeric',
44 2
            'salary_max' => 'required|numeric',
45 2
            'noc' => 'required|numeric',
46 2
            'classification_code' => 'required|regex:/[A-Z]{2}/',
47 2
            'classification_level' => 'required|numeric',
48 2
            'remote_work_allowed' => 'required|boolean',
49 2
            'en.city' => 'required|string',
50 2
            'en.title' => 'required|string',
51 2
            'en.team_impact' => 'required|string',
52 2
            'en.hire_impact' => 'required|string',
53 2
            'en.division' => 'required|string',
54 2
            'en.education' => 'required|string',
55 2
            'fr.city' => 'required|string',
56 2
            'fr.title' => 'required|string',
57 2
            'fr.team_impact' => 'required|string',
58 2
            'fr.hire_impact' => 'required|string',
59 2
            'fr.division' => 'required|string',
60 2
            'fr.education' => 'required|string',
61
        ];
62
    }
63
}
64