Passed
Branch master (328f34)
by Chubarov
04:39
created

TaskRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
dl 0
loc 43
ccs 15
cts 15
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A rules() 0 9 1
A messages() 0 13 1
1
<?php
2
3
namespace agoalofalife\postman\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
class TaskRequest extends FormRequest
8
{
9
    /**
10
     * Determine if the user is authorized to make this request.
11
     *
12
     * @return bool
13
     */
14 2
    public function authorize() : bool
15
    {
16
        // TODO check request to xhr in middleware
17 2
        return true;
18
    }
19
20
    /**
21
     * Get the validation rules that apply to the request.
22
     *
23
     * @return array
24
     */
25 2
    public function rules() : array
26
    {
27
        return [
28 2
            'date' => 'required|date_format:"Y-m-d H:i:s"',
29
            'theme' => 'required',
30
            'text' => 'required',
31
            'mode' => 'required|exists:mode_post_emails,id',
32
            'users' => 'required|array',
33
            'users.*' => 'required|exists:users,id'
34
        ];
35
    }
36
37 2
    public function messages() : array
38
    {
39
        return [
40 2
            'date.required' => trans('postman::requestMessage.createTask.date.required'),
41 2
            'date.date_format' => trans('postman::requestMessage.createTask.date.date_format'),
42 2
            'theme.required' => trans('postman::requestMessage.createTask.theme.required'),
43 2
            'text.required' => trans('postman::requestMessage.createTask.text.required'),
44 2
            'mode.required' => trans('postman::requestMessage.createTask.mode.required'),
45 2
            'mode.exists' => trans('postman::requestMessage.createTask.mode.exists'),
46 2
            'users.required' => trans('postman::requestMessage.createTask.mode.exists'),
47 2
            'users.array' => trans('postman::requestMessage.createTask.users.array'),
48 2
            'users.*.required' => trans('postman::requestMessage.createTask.users.*.required'),
49 2
            'users.*.exists' => trans('postman::requestMessage.createTask.users.*.exists')
50
        ];
51
    }
52
}
53