Completed
Pull Request — master (#107)
by Glenn
104:21 queued 64:56
created

DepartmentsValidator::wantsJson()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
3
namespace App\Http\Requests;
4
5
use App\Http\Requests\Request;
6
7
class DepartmentsValidator extends Request
8
{
9
    /**
10
     * Determine if the application is on the api or not.
11
     *
12
     * If on the API = json errorbag
13
     * if on the WEB = array messagebag
14
     * @return bool
15
     */
16
    public function wantsJson()
17
    {
18
        return Request::is('api/*') ? true : false;
19
    }
20
21
    /**
22
     * Determine if the user is authorized to make this request.
23
     *
24
     * @return bool
25
     */
26
    public function authorize()
27
    {
28
        return true;
29
    }
30
31
    /**
32
     * Get the validation rules that apply to the request.
33
     *
34
     * @return array
35
     */
36
    public function rules()
37
    {
38
        return [
39
            'department_name'    => 'required',
40
            'department_manager' => 'required',
41
        ];
42
    }
43
}
44