Completed
Pull Request — master (#183)
by Cristian
03:37 queued 01:44
created

AccountInfoRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 32
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 4

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\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
     * Get the validation rules that apply to the request.
24
     *
25
     * @return array
26
     */
27
    public function rules()
28
    {
29
        $user = Auth::user();
30
31
        return [
32
            'email' => [
33
                'required',
34
                'email',
35
                Rule::unique($user->getTable())->ignore($user->getKey()),
36
            ],
37
            'name' => 'required',
38
        ];
39
    }
40
}
41