Completed
Pull Request — master (#21)
by ARCANEDEV
05:07
created

UsersRoutes::map()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 51
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 32
CRAP Score 2.0054

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 51
ccs 32
cts 36
cp 0.8889
rs 9.4109
c 2
b 0
f 0
cc 2
eloc 33
nc 1
nop 0
crap 2.0054

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php namespace Arcanesoft\Auth\Http\Routes\Admin;
2
3
use Arcanedev\LaravelAuth\Services\UserImpersonator;
4
use Arcanedev\Support\Routing\RouteRegistrar;
5
use Arcanesoft\Auth\Models\User;
6
7
/**
8
 * Class     UsersRoutes
9
 *
10
 * @package  Arcanesoft\Auth\Http\Routes\Admin
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class UsersRoutes extends RouteRegistrar
14
{
15
    /* -----------------------------------------------------------------
16
     |  Main Methods
17
     | -----------------------------------------------------------------
18
     */
19
    /**
20
     * Map routes.
21
     */
22 12
    public function map()
23
    {
24
        $this->bind('auth_user', function($hashedId) {
25
            return User::firstHashedOrFail($hashedId);
26 12
        });
27
28
        $this->prefix('users')->name('users.')->group(function () {
29 12
            $this->get('/', 'UsersController@index')
30 12
                 ->name('index'); // admin::auth.users.index
31
32 12
            $this->get('trash', 'UsersController@trashList')
33 12
                 ->name('trash'); // admin::auth.users.trash
34
35 12
            $this->get('roles-filter/{auth_role}', 'UsersController@listByRole')
36 12
                 ->name('roles-filter.index'); // admin::auth.users.roles-filter.index
37
38 12
            $this->get('create', 'UsersController@create')
39 12
                 ->name('create'); // admin::auth.users.create
40
41 12
            $this->post('store', 'UsersController@store')
42 12
                 ->name('store'); // admin::auth.users.store
43
44 12
            $this->prefix('{auth_user}')->group(function () {
45 12
                $this->get('/', 'UsersController@show')
46 12
                     ->name('show'); // admin::auth.users.show
47
48 12
                $this->get('edit', 'UsersController@edit')
49 12
                     ->name('edit'); // admin::auth.users.edit
50
51 12
                $this->put('update', 'UsersController@update')
52 12
                     ->name('update'); // admin::auth.users.update
53
54 12
                $this->middleware('ajax')
55 12
                     ->put('activate', 'UsersController@activate')
56 12
                     ->name('activate'); // admin::auth.users.activate
57
58 12
                $this->middleware('ajax')
59 12
                     ->put('restore', 'UsersController@restore')
60 12
                     ->name('restore'); // admin::auth.users.restore
61
62 12
                $this->middleware('ajax')
63 12
                     ->delete('delete', 'UsersController@delete')
64 12
                     ->name('delete'); // admin::auth.users.delete
65
66 12
                if (UserImpersonator::isEnabled()) {
67
                    $this->get('impersonate', 'UsersController@impersonate')
68
                         ->name('impersonate'); // admin::auth.users.impersonate
69
                }
70 12
            });
71 12
        });
72 12
    }
73
}
74