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

DocumentRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 57
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 5 1
A rules() 0 12 1
A attributes() 0 8 1
A messages() 0 6 1
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