@@ 8-41 (lines=34) @@ | ||
5 | use App\User; |
|
6 | use Illuminate\Foundation\Http\FormRequest; |
|
7 | ||
8 | class StoreUserFormRequest extends FormRequest |
|
9 | { |
|
10 | /** |
|
11 | * Determine if the user is authorized to make this request. |
|
12 | * |
|
13 | * @return bool |
|
14 | */ |
|
15 | public function authorize() |
|
16 | { |
|
17 | return auth()->user()->can('update', new User); |
|
18 | } |
|
19 | ||
20 | /** |
|
21 | * Get the validation rules that apply to the request. |
|
22 | * |
|
23 | * @return array |
|
24 | */ |
|
25 | public function rules() |
|
26 | { |
|
27 | return [ |
|
28 | 'name' => ['required', 'string'] |
|
29 | ]; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * Get custom messages for validator errors. |
|
34 | * |
|
35 | * @return array |
|
36 | */ |
|
37 | public function messages() |
|
38 | { |
|
39 | return trans('microboard::users.fields'); |
|
40 | } |
|
41 | } |
|
42 |
@@ 7-40 (lines=34) @@ | ||
4 | ||
5 | use Illuminate\Foundation\Http\FormRequest; |
|
6 | ||
7 | class UpdateUserFormRequest extends FormRequest |
|
8 | { |
|
9 | /** |
|
10 | * Determine if the user is authorized to make this request. |
|
11 | * |
|
12 | * @return bool |
|
13 | */ |
|
14 | public function authorize() |
|
15 | { |
|
16 | return auth()->user()->can('update', $this->user); |
|
17 | } |
|
18 | ||
19 | /** |
|
20 | * Get the validation rules that apply to the request. |
|
21 | * |
|
22 | * @return array |
|
23 | */ |
|
24 | public function rules() |
|
25 | { |
|
26 | return [ |
|
27 | 'name' => ['required', 'string'] |
|
28 | ]; |
|
29 | } |
|
30 | ||
31 | /** |
|
32 | * Get custom messages for validator errors. |
|
33 | * |
|
34 | * @return array |
|
35 | */ |
|
36 | public function messages() |
|
37 | { |
|
38 | return trans('microboard::users.fields'); |
|
39 | } |
|
40 | } |
|
41 |