1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Requests; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Http\FormRequest; |
6
|
|
|
use App\Services\Validation\Rules\ValidIdRule; |
7
|
|
|
use App\Models\Lookup\Frequency; |
8
|
|
|
use App\Models\Lookup\Department; |
9
|
|
|
use App\Services\Validation\Rules\LinkedInUrlRule; |
10
|
|
|
use Illuminate\Validation\Rule; |
11
|
|
|
use App\Services\Validation\Rules\PasswordCorrectRule; |
12
|
|
|
use App\Services\Validation\Rules\PasswordFormatRule; |
13
|
|
|
use App\Services\Validation\Rules\TwitterHandleRule; |
14
|
|
|
|
15
|
|
|
class UpdateManagerProfileRequest extends FormRequest |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Validator instance updated on failedValidation. |
19
|
|
|
* |
20
|
|
|
* @var \Illuminate\Contracts\Validation\Validator |
21
|
|
|
*/ |
22
|
|
|
public $validator = null; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Determine if the user is authorized to make this request. |
26
|
|
|
* |
27
|
|
|
* @return boolean |
28
|
|
|
*/ |
29
|
|
|
public function authorize() |
30
|
|
|
{ |
31
|
|
|
return $this->manager !== null; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
|
|
|
|
35
|
|
|
* Override Handle a failed validation attempt. |
36
|
|
|
* |
37
|
|
|
* @return void |
38
|
|
|
*/ |
39
|
|
|
protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator) |
40
|
|
|
{ |
41
|
|
|
$this->validator = $validator; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Get the validation rules that apply to the request. |
46
|
|
|
* |
47
|
|
|
* @return array |
48
|
|
|
*/ |
49
|
|
|
public function rules() |
50
|
|
|
{ |
51
|
|
|
$frequencyRule = new ValidIdRule(Frequency::class); |
52
|
|
|
return [ |
53
|
|
|
'name' => 'required|string|max:191', |
54
|
|
|
'email' => [ |
55
|
|
|
'required', |
56
|
|
|
'string', |
57
|
|
|
'max:191', |
58
|
|
|
'email', |
59
|
|
|
// Email may match existing email for this user, |
60
|
|
|
// but must be unique if changed. |
61
|
|
|
Rule::unique('users', 'email')->ignore($this->manager->user->id) |
62
|
|
|
], |
63
|
|
|
'gov_email' => [ |
64
|
|
|
'nullable', |
65
|
|
|
'string', |
66
|
|
|
'max:191', |
67
|
|
|
'email', |
68
|
|
|
], |
69
|
|
|
// Password validation |
70
|
|
|
'current_password' => [ |
71
|
|
|
'nullable', |
72
|
|
|
'required_with:new_password', |
73
|
|
|
new PasswordCorrectRule |
74
|
|
|
], |
75
|
|
|
'new_password' => [ |
76
|
|
|
'nullable', |
77
|
|
|
'min:8', |
78
|
|
|
new PasswordFormatRule, |
79
|
|
|
'confirmed' |
80
|
|
|
], |
81
|
|
|
|
82
|
|
|
'department_id' => ['required', new ValidIdRule(Department::class)], |
83
|
|
|
'telework_allowed_frequency_id' => ['required', $frequencyRule], |
84
|
|
|
'flexible_hours_frequency_id' => ['required', $frequencyRule], |
85
|
|
|
|
86
|
|
|
'team_size' => 'nullable|numeric|min:1', |
87
|
|
|
'years_experience' => 'nullable|numeric|min:0', |
88
|
|
|
'gc_directory_url' => 'nullable|url', |
89
|
|
|
|
90
|
|
|
'*.about_me' => 'nullable|string', |
91
|
|
|
'*.career_journey' => 'nullable|string', |
92
|
|
|
'*.branch' => 'nullable|string', |
93
|
|
|
'*.division' => 'nullable|string', |
94
|
|
|
'*.education' => 'nullable|string', |
95
|
|
|
'*.employee_learning' => 'nullable|string', |
96
|
|
|
'*.expectations' => 'nullable|string', |
97
|
|
|
'*.greatest_accomplishment' => 'nullable|string', |
98
|
|
|
'*.how_we_work' => 'nullable|string', |
99
|
|
|
'*.leadership_style' => 'nullable|string', |
100
|
|
|
'*.learning_path' => 'nullable|string', |
101
|
|
|
'*.operating_context' => 'nullable|string', |
102
|
|
|
'*.position' => 'nullable|string', |
103
|
|
|
'*.things_to_know' => 'nullable|string', |
104
|
|
|
'*.what_we_value' => 'nullable|string', |
105
|
|
|
|
106
|
|
|
'twitter_username' => [ |
107
|
|
|
'nullable', // Some people may not have a handle. |
108
|
|
|
new TwitterHandleRule, |
109
|
|
|
], |
110
|
|
|
'linkedin_url' => [ |
111
|
|
|
'nullable', // Some people may not be on LinkedIn. |
112
|
|
|
new LinkedInUrlRule, |
113
|
|
|
], |
114
|
|
|
]; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|