Passed
Push — master ( d487d9...59950a )
by Ron
02:58 queued 12s
created

CustomerContactsRequest::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Requests\Customers;
4
5
use App\Models\CustomerContact;
6
use Illuminate\Foundation\Http\FormRequest;
7
8
class CustomerContactsRequest extends FormRequest
9
{
10
    /**
11
     * Determine if the user is authorized to make this request
12
     */
13
    public function authorize()
14
    {
15
        if($this->route('contact'))
16
        {
17
            return $this->user()->can('update', CustomerContact::find($this->route('contact')));
18
        }
19
20
        return $this->user()->can('create', CustomerContact::class);
21
    }
22
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
            'name'    => 'required|string',
31
            'title'   => 'nullable|string',
32
            'email'   => 'nullable|email',
33
            'note'    => 'nullable|string',
34
            'shared'  => 'required|boolean',
35
            'phones'  => 'nullable|array',
36
        ];
37
    }
38
}
39