UpdateUserRequest::authorize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Requests\User;
4
5
use App\Models\User;
6
7
use Illuminate\Validation\Rule;
8
use Illuminate\Foundation\Http\FormRequest;
9
10
class UpdateUserRequest extends FormRequest
11
{
12
    /**
13
     * Determine if the user is authorized to make this request.
14
     */
15
    public function authorize()
16
    {
17
        return $this->user()->can('update', User::find($this->route('setting')));
18
    }
19
20
    /**
21
     * Get the validation rules that apply to the request
22
     */
23
    public function rules()
24
    {
25
        return [
26
            'first_name' => 'required|string',
27
            'last_name'  => 'required|string',
28
            'email'      => [
29
                'required',
30
                'email',
31
                Rule::unique('users')->ignore($this->user()->user_id, 'user_id'),
32
            ]
33
        ];
34
    }
35
}
36