Passed
Push — dev6 ( 72e99e...1f4a51 )
by Ron
18:35
created

CustomerNoteRequest::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 6
c 3
b 0
f 0
dl 0
loc 8
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Http\Requests\Customers;
4
5
use App\Models\CustomerNote;
6
use Illuminate\Foundation\Http\FormRequest;
7
8
class CustomerNoteRequest 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('note'))
16
        {
17 6
            return $this->user()->can('update', CustomerNote::find($this->route('note')));
18
        }
19 3
20
        return $this->user()->can('create', CustomerNote::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
            'subject' => 'required|string',
31
            'details' => 'required|string',
32
            'shared'  => 'required|boolean',
33 4
            'urgent'  => 'required|boolean',
34
        ];
35
    }
36
}
37