Completed
Pull Request — master (#107)
by Glenn
15:22 queued 07:05
created

DepartmentsValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A wantsJson() 0 4 2
A authorize() 0 4 1
A rules() 0 7 1
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