VendorUpdateFormRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A authorize() 0 4 1
A rules() 0 9 1
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
}