Passed
Push — dev6 ( 1f4a51...d7b093 )
by Ron
16:11
created

CustomerFileRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 2
b 0
f 0
dl 0
loc 25
rs 10
ccs 5
cts 5
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 8 2
A rules() 0 7 1
1
<?php
2
3
namespace App\Http\Requests\Customers;
4
5
use App\Models\CustomerFile;
6
use Illuminate\Foundation\Http\FormRequest;
7
8
class CustomerFileRequest extends FormRequest
9
{
10
    /**
11
     * Determine if the user is authorized to make this request
12
     */
13
    public function authorize()
14
    {
15 6
        if($this->route('file'))
16
        {
17 6
            return $this->user()->can('update', CustomerFile::find($this->route('file')));
18
        }
19 3
20
        return $this->user()->can('create', CustomerFile::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
            'name'    => 'required|string',
31
            'type'    => 'required|string',
32
            'shared'  => 'required|boolean',
33 4
        ];
34
    }
35
}
36