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

NoteRequest::getValidatorInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
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