develop
Last change
on this file since e651d0d was e6c1f87, checked in by beratkjufliju <kufliju@…>, 3 years ago |
added pagination, is_important
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Http\Requests\Dashboard;
|
---|
4 |
|
---|
5 | use Illuminate\Foundation\Http\FormRequest;
|
---|
6 | use Illuminate\Contracts\Validation\Validator;
|
---|
7 | use Illuminate\Validation\ValidationException;
|
---|
8 |
|
---|
9 | class UsernameSettingsRequest extends FormRequest
|
---|
10 | {
|
---|
11 | /**
|
---|
12 | * Determine if the user is authorized to make this request.
|
---|
13 | *
|
---|
14 | * @return bool
|
---|
15 | */
|
---|
16 | public function authorize()
|
---|
17 | {
|
---|
18 | return true;
|
---|
19 | }
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Get the validation rules that apply to the request.
|
---|
23 | *
|
---|
24 | * @return array
|
---|
25 | */
|
---|
26 | public function rules()
|
---|
27 | {
|
---|
28 | return [
|
---|
29 | "username" => "required|alpha_dash|min:5|unique:users,username,$this->id,id"
|
---|
30 | ];
|
---|
31 | }
|
---|
32 |
|
---|
33 | protected function failedValidation(Validator $validator)
|
---|
34 | {
|
---|
35 | $response = redirect()
|
---|
36 | ->route('dashboard.settings.index')
|
---|
37 | ->withInput(['active_tab' => 'security'])
|
---|
38 | ->withErrors($validator);
|
---|
39 |
|
---|
40 | throw (new ValidationException($validator))
|
---|
41 | ->errorBag($this->errorBag)
|
---|
42 | ->redirectTo($this->getRedirectUrl());
|
---|
43 | }
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.