Passed
Push — master ( d4d78d...6ceb34 )
by Stephen
11:07 queued 13s
created

TrackRequest::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Sfneal\Tracking\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
// todo: add to controllers package?
8
class TrackRequest extends FormRequest
9
{
10
    /**
11
     * TrackRequest constructor.
12
     *
13
     * @param array                $query      The GET parameters
14
     * @param array                $request    The POST parameters
15
     * @param array                $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
16
     * @param array                $cookies    The COOKIE parameters
17
     * @param array                $files      The FILES parameters
18
     * @param array                $server     The SERVER parameters
19
     * @param string|resource|null $content    The raw body data
20
     */
21
    public function __construct(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
22
    {
23
        parent::__construct($query, $request, $attributes, $cookies, $files, $server, $content);
24
25
        // Set container
26
        $this->setContainer(app());
27
28
        // Get validator instance
29
        $this->getValidatorInstance();
30
    }
31
32
    /**
33
     * Determine if the user is authorized to make this request.
34
     *
35
     * @return bool
36
     */
37
    public function authorize(): bool
38
    {
39
        return true;
40
    }
41
42
    /**
43
     * Get the validation rules that apply to the request.
44
     *
45
     * @return array
46
     */
47
    public function rules(): array
48
    {
49
        return [
50
            'table' => ['string', 'nullable'],
51
            'user' => ['integer', 'nullable'],
52
            'users' => ['array', 'nullable'],
53
            'key' => ['integer', 'nullable'],
54
            'period' => ['array', 'nullable'],
55
        ];
56
    }
57
}
58