Passed
Push — develop ( 9324e6...f3eb57 )
by Septianata
04:31
created

AbstractRequest::authorize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Http\Requests\User;
4
5
use App\Infrastructure\Foundation\Http\FormRequest;
6
use App\Models\Branch;
7
8
abstract class AbstractRequest extends FormRequest
9
{
10
    /**
11
     * {@inheritDoc}
12
     */
13 2
    public function authorize()
14
    {
15 2
        return !is_null($this->user());
16
    }
17
18
    /**
19
     * {@inheritDoc}
20
     */
21 2
    public function attributes()
22
    {
23
        return [
24 2
            'branch_id' => trans('admin-lang.branch'),
25 2
            'username' => trans('Username'),
26 2
            'fullname' => trans('Full name'),
27 2
            'gender' => trans('Gender'),
28 2
            'email' => trans('Email'),
29 2
            'phone_country' => trans('Phone Country'),
30 2
            'phone' => trans('Phone Number'),
31 2
            'role' => trans('Role'),
32 2
            'is_active' => trans('Active'),
33
        ];
34
    }
35
36
    /**
37
     * Return branch model based on the request.
38
     *
39
     * @param  string  $key
40
     * @return \App\Models\Branch
41
     */
42 2
    public function getBranch(string $key = 'branch_id'): Branch
43
    {
44 2
        return Branch::find($this->input($key));
45
    }
46
}
47