Completed
Push — master ( 36900a...12dd06 )
by Cristian
04:37
created

AccountInfoRequest::validationData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 2
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Backpack\Base\app\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Validation\Rule;
8
9
class AccountInfoRequest extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @return bool
15
     */
16
    public function authorize()
17
    {
18
        // only allow updates if the user is logged in
19
        return Auth::check();
20
    }
21
22
    /**
23
     * Restrict the fields that the user can change.
24
     *
25
     * @return array
26
     */
27
    protected function validationData()
28
    {
29
        return $this->only('email', 'name');
30
    }
31
32
    /**
33
     * Get the validation rules that apply to the request.
34
     *
35
     * @return array
36
     */
37
    public function rules()
38
    {
39
        $user = Auth::user();
40
41
        return [
42
            'email' => [
43
                'required',
44
                'email',
45
                Rule::unique($user->getTable())->ignore($user->getKey()),
46
            ],
47
            'name' => 'required',
48
        ];
49
    }
50
}
51