Code Duplication    Length = 47-47 lines in 2 locations

src/Http/Requests/PageRequest.php 1 location

@@ 8-54 (lines=47) @@
5
use Illuminate\Http\Request;
6
use Illuminate\Foundation\Http\FormRequest;
7
8
class PageRequest extends FormRequest
9
{
10
    /**
11
     * Determine if the user is authorized to make this request.
12
     *
13
     * @return bool
14
     */
15
    public function authorize()
16
    {
17
        return true;
18
    }
19
20
    /**
21
     * Get the validation rules that apply to the request.
22
     *
23
     * @return array
24
     */
25
    public function rules(Request $request)
26
    {
27
        $id = $request->input('id');
28
29
        $nameRule = 'required_with:type,links,lines,blocks|unique:pages,name';
30
31
        if ($id) {
32
            $nameRule .= ','.$id;
33
        }
34
35
        return [
36
            'name'          => $nameRule,
37
            'blocks.*.text' => 'required',
38
        ];
39
    }
40
41
    /**
42
     * Error messages for validation rules.
43
     *
44
     * @return array
45
     */
46
    public function messages()
47
    {
48
        return [
49
            'name.required_with'     => 'Page name is required.',
50
            'name.unique'            => 'Page name is already taken.',
51
            'blocks.*.text.required' => 'All blocks must have text.'
52
        ];
53
    }
54
}
55

src/Http/Requests/ProjectRequest.php 1 location

@@ 8-54 (lines=47) @@
5
use Illuminate\Http\Request;
6
use Illuminate\Foundation\Http\FormRequest;
7
8
class ProjectRequest extends FormRequest
9
{
10
    /**
11
     * Determine if the user is authorized to make this request.
12
     *
13
     * @return bool
14
     */
15
    public function authorize()
16
    {
17
        return true;
18
    }
19
20
    /**
21
     * Get the validation rules that apply to the request.
22
     *
23
     * @return array
24
     */
25
    public function rules(Request $request)
26
    {
27
        $id = $request->input('id');
28
29
        $nameRule = 'required_with:type,links,lines,blocks|unique:projects,name';
30
31
        if ($id) {
32
            $nameRule .= ','.$id;
33
        }
34
35
        return [
36
            'name'          => $nameRule,
37
            'blocks.*.text' => 'required',
38
        ];
39
    }
40
41
    /**
42
     * Error messages for validation rules.
43
     *
44
     * @return array
45
     */
46
    public function messages()
47
    {
48
        return [
49
            'name.required_with'     => 'Project name is required.',
50
            'name.unique'            => 'Project name is already taken.',
51
            'blocks.*.text.required' => 'All blocks must have text.'
52
        ];
53
    }
54
}
55