Test Failed
Push — master ( 02a63f...ddb4ba )
by Oliver
05:18
created

DocumentRequest::attributes()   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
namespace Webfactor\Laravel\Backpack\Documents\Requests;
4
5
use App\Http\Requests\Request;
6
use Illuminate\Validation\Rule;
7
8
class DocumentRequest extends \Backpack\CRUD\app\Http\Requests\CrudRequest
9
{
10
    /**
11
     * Determine if the user is authorized to make this request.
12
     *
13
     * @return bool
14
     */
15
    public function authorize()
16
    {
17
        // only allow updates if the user is logged in
18
        return \Auth::check();
19
    }
20
21
    /**
22
     * Get the validation rules that apply to the request.
23
     *
24
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,array<strin...n\Rules\Unique>|string>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
25
     */
26
    public function rules()
27
    {
28
        return [
29
            'type'  => [
30
                'required',
31
                Rule::in(config('webfactor.documents.types')),
32
                Rule::unique('documents')
33
            ],
34
            'title' => 'required|min:5|max:255',
35
            'body'  => 'required|string'
36
        ];
37
    }
38
39
    /**
40
     * Get the validation attributes that apply to the request.
41
     *
42
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,\Illuminate...ator|string|array|null>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
43
     */
44
    public function attributes()
45
    {
46
        return [
47
            'type' => trans('webfactor::documents.type'),
48
            'title' => trans('webfactor::documents.title'),
49
            'body' => trans('webfactor::documents.body')
50
        ];
51
    }
52
53
    /**
54
     * Get the validation messages that apply to the request.
55
     *
56
     * @return array
57
     */
58
    public function messages()
59
    {
60
        return [
61
            //
62
        ];
63
    }
64
}
65