StoreBlogPost::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Bantenprov\VueBlog\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
class StoreBlogPost 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 true;
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
            'title' => 'required|unique:blog|max:255|min:3',
28
            'content' => 'required',
29
        ];
30
    }
31
32 View Code Duplication
    public function messages()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        $messages = [
35
            'title.required' => 'Er, you forgot to add a title!',
36
            'title.min' => 'Don\'t be stingy - make the title LONGER THAN 3 CHARACTERS!',
37
            'content.required' => 'No body, no article.'
38
        ];
39
40
        if ('PATCH' === $this->method()){
41
42
            $messages = [
43
                'title.required' => 'Empty Title not allowed on PATCH',
44
                'title.min' => 'Don\'t be stingy - make the title LONGER THAN 3 CHARACTERS!',
45
                'content.required' => 'No body, no article.'
46
            ];
47
48
        }
49
50
        return $messages;
51
    }
52
}
53