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

AbstractRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 37
ccs 14
cts 14
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 3 1
A attributes() 0 12 1
A getBranch() 0 3 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