Last change
on this file since 0c07a90 was 0924b6c, checked in by Özkan İliyaz <iliyaz_96@…>, 4 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1001 bytes
|
Rev | Line | |
---|
[0924b6c] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace App\Http\Requests\Blog;
|
---|
| 4 |
|
---|
| 5 | use Illuminate\Contracts\Validation\Validator;
|
---|
| 6 | use Illuminate\Foundation\Http\FormRequest;
|
---|
| 7 |
|
---|
| 8 | class CommentRequest extends FormRequest
|
---|
| 9 | {
|
---|
| 10 | public $validator = null;
|
---|
| 11 |
|
---|
| 12 | /**
|
---|
| 13 | * Determine if the user is authorized to make this request.
|
---|
| 14 | *
|
---|
| 15 | * @return bool
|
---|
| 16 | */
|
---|
| 17 | public function authorize()
|
---|
| 18 | {
|
---|
| 19 | return true;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * Get the validation rules that apply to the request.
|
---|
| 24 | *
|
---|
| 25 | * @return array
|
---|
| 26 | */
|
---|
| 27 | public function rules()
|
---|
| 28 | {
|
---|
| 29 | return [
|
---|
| 30 | "name" => "required|string|min:2",
|
---|
| 31 | "email" => "required|email|max:255",
|
---|
| 32 | "comment" => "required|min:2",
|
---|
| 33 | "post_id" => "required|exists:posts,id"
|
---|
| 34 | ];
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | public function failedValidation(Validator $validator)
|
---|
| 38 | {
|
---|
| 39 | if($validator->fails()) {
|
---|
| 40 | return [
|
---|
| 41 | "type" => "alert-danger",
|
---|
| 42 | "message" => "Please check the input fields"
|
---|
| 43 | ];
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.