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

CustomerContactsRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 1
b 0
f 0
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 8 2
A rules() 0 10 1
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