|
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
|
|
|
return [ |
|
52
|
|
|
'first_name' => 'required|string|max:191', |
|
53
|
|
|
'last_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
|
|
|
|
|
84
|
|
|
'years_experience' => 'nullable|numeric|min:0', |
|
85
|
|
|
'gc_directory_url' => 'nullable|url', |
|
86
|
|
|
|
|
87
|
|
|
'*.about_me' => 'nullable|string', |
|
88
|
|
|
'*.career_journey' => 'nullable|string', |
|
89
|
|
|
'*.division' => 'nullable|string', |
|
90
|
|
|
'*.education' => 'nullable|string', |
|
91
|
|
|
'*.employee_learning' => 'nullable|string', |
|
92
|
|
|
'*.expectations' => 'nullable|string', |
|
93
|
|
|
'*.greatest_accomplishment' => 'nullable|string', |
|
94
|
|
|
'*.leadership_style' => 'nullable|string', |
|
95
|
|
|
'*.learning_path' => 'nullable|string', |
|
96
|
|
|
'*.position' => 'nullable|string', |
|
97
|
|
|
|
|
98
|
|
|
'twitter_username' => [ |
|
99
|
|
|
'nullable', // Some people may not have a handle. |
|
100
|
|
|
new TwitterHandleRule, |
|
101
|
|
|
], |
|
102
|
|
|
'linkedin_url' => [ |
|
103
|
|
|
'nullable', // Some people may not be on LinkedIn. |
|
104
|
|
|
new LinkedInUrlRule, |
|
105
|
|
|
], |
|
106
|
|
|
]; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|