UpdateUserRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 22
rs 10

2 Methods

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