Completed
Pull Request — master (#183)
by Cristian
10:44
created

AccountInfoRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 5 1
A rules() 0 13 1
1
<?php
2
3
namespace Backpack\Base\app\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Validation\Rule;
7
8
class AccountInfoRequest extends FormRequest
9
{
10
    /**
11
     * Determine if the user is authorized to make this request.
12
     *
13
     * @return bool
14
     */
15
    public function authorize()
16
    {
17
        // only allow updates if the user is logged in
18
        return \Auth::check();
19
    }
20
21
    /**
22
     * Get the validation rules that apply to the request.
23
     *
24
     * @return array
25
     */
26
    public function rules()
27
    {
28
        $user = \Auth::user();
29
30
        return [
31
            'email' => [
32
                'required',
33
                'email',
34
                Rule::unique($user->getTable())->ignore($user->getKey()),
35
            ],
36
            'name' => 'required',
37
        ];
38
    }
39
}
40