VendorUpdateFormRequest::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Requests;
4
5
use Illuminate\Contracts\Auth\Guard;
6
7
class VendorUpdateFormRequest extends Request
8
{
9
    /**
10
     * @var Guard
11
     */
12
    private $auth;
13
14
    /**
15
     * VendorUpdateFormRequest constructor.
16
     * @param Guard $auth
17
     */
18
    public function __construct(Guard $auth)
19
    {
20
        parent::__construct();
21
22
        $this->auth = $auth;
23
    }
24
25
    /**
26
     * Determine if the user is authorized to make this request.
27
     *
28
     * @return bool
29
     */
30
    public function authorize()
31
    {
32
        return $this->route('vendor')->user_id == $this->auth->id();
33
    }
34
35
    /**
36
     * Get the validation rules that apply to the request.
37
     *
38
     * @return array
39
     */
40
    public function rules()
41
    {
42
        return [
43
            'name' => 'required|min:3|max:250|unique:vendors,name,' . $this->route('vendor')->id,
44
            'email' => 'email',
45
            'phone' => 'required|digits:8',
46
            'description' => 'min:10|max:250'
47
        ];
48
    }
49
}