Passed
Push — dev6 ( 85d655...fe3508 )
by Ron
18:08
created

EquipmentCategoryRequest::authorize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 3
c 2
b 0
f 0
dl 0
loc 8
rs 10
ccs 2
cts 2
cp 1
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace App\Http\Requests\Equipment;
4
5
use App\Models\EquipmentCategory;
6
use App\Models\EquipmentType;
7
use Illuminate\Foundation\Http\FormRequest;
8
9
class EquipmentCategoryRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request
13
     */
14 4
    public function authorize()
15
    {
16 4
        if($this->route('equipment_category'))
17
        {
18
            return $this->user()->can('update', EquipmentCategory::find($this->route('equipment_category')));
19
        }
20
21
        return $this->user()->can('create', EquipmentCategory::class);
22 2
    }
23
24
    /**
25
     * Get the validation rules that apply to the request
26 2
     */
27
    public function rules()
28
    {
29
        return [
30
            'name' => 'required|unique:equipment_categories,name,'.$this->route('equipment_category').',cat_id',
31
        ];
32
    }
33
}
34