Completed
Push — master ( f01bc0...7860e5 )
by Renato
02:43
created

NoteRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 46
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A rules() 0 6 1
A messages() 0 7 1
A getValidatorInstance() 0 8 1
1
<?php
2
/**
3
 * GitScrum v0.1.
4
 *
5
 * @author  Renato Marinho <[email protected]>
6
 * @license http://opensource.org/licenses/GPL-3.0 GPLv3
7
 */
8
9
namespace GitScrum\Http\Requests;
10
11
use Illuminate\Foundation\Http\FormRequest;
12
13
class NoteRequest extends FormRequest
14
{
15
    /**
16
     * Determine if the user is authorized to make this request.
17
     *
18
     * @return bool
19
     */
20
    public function authorize()
21
    {
22
        return true;
23
    }
24
25
    /**
26
     * Get the validation rules that apply to the request.
27
     *
28
     * @return array
29
     */
30
    public function rules()
31
    {
32
        return [
33
            'frm_notes_title' => 'required|min:2',
34
        ];
35
    }
36
37
    /**
38
     * Get the error messages for the defined validation rules.
39
     *
40
     * @return array
41
     */
42
    public function messages()
43
    {
44
        return [
45
            'frm_notes_title.required' => trans('Field cannot be blank'),
46
            'frm_notes_title.min' => trans('Field must be at least 2 characters'),
47
        ];
48
    }
49
50
    protected function getValidatorInstance()
51
    {
52
        $data = $this->all();
53
        $data['title'] = $data['frm_notes_title'];
54
        $this->getInputSource()->replace($data);
55
56
        return parent::getValidatorInstance();
57
    }
58
}
59