Completed
Pull Request — master (#183)
by Cristian
09:51 queued 07:42
created

AccountInfoRequest::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 9.4285
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