Passed
Push — dev6 ( 6ea9a3...2cfb0e )
by Ron
15:41
created

CustomerEquipmentRequest::authorize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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