Completed
Push — master ( e40024...27a431 )
by ARCANEDEV
03:09
created

UsersRoutes::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 66
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 52
CRAP Score 1

Importance

Changes 9
Bugs 0 Features 0
Metric Value
c 9
b 0
f 0
dl 0
loc 66
ccs 52
cts 53
cp 0.9811
rs 9.3191
cc 1
eloc 40
nc 1
nop 1
crap 1

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\Foundation;
2
3
use Arcanedev\Support\Bases\RouteRegister;
4
use Arcanesoft\Auth\Models\User;
5
use Illuminate\Contracts\Routing\Registrar;
6
7
/**
8
 * Class     UsersRoutes
9
 *
10
 * @package  Arcanesoft\Auth\Http\Routes\Foundation
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class UsersRoutes extends RouteRegister
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Main Functions
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Map routes.
21
     *
22
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
23
     */
24 24
    public function map(Registrar $router)
25
    {
26 24
        $this->group([
27 24
            'prefix'    => 'users',
28 18
            'as'        => 'users.',
29
        ], function () {
30 24
            $this->get('/', [
31 24
                'as'   => 'index',         // auth::foundation.users.index
32 18
                'uses' => 'UsersController@index',
33 18
            ]);
34
35 24
            $this->get('trash', [
36 24
                'as'   => 'trash',         // auth::foundation.users.trash
37 18
                'uses' => 'UsersController@trashList',
38 18
            ]);
39
40 24
            $this->get('roles-filter/{role_id}', [
41 24
                'as'   => 'roles-filter.index',  // auth::foundation.users.roles-filter.index
42 18
                'uses' => 'UsersController@listByRole',
43 18
            ]);
44
45 24
            $this->get('create', [
46 24
                'as'   => 'create',        // auth::foundation.users.create
47 18
                'uses' => 'UsersController@create',
48 18
            ]);
49
50 24
            $this->post('store', [
51 24
                'as'   => 'store',         // auth::foundation.users.store
52 18
                'uses' => 'UsersController@store',
53 18
            ]);
54
55 24
            $this->get('{user_id}/show', [
56 24
                'as'   => 'show',          // auth::foundation.users.show
57 18
                'uses' => 'UsersController@show',
58 18
            ]);
59
60 24
            $this->get('{user_id}/edit', [
61 24
                'as'   => 'edit',          // auth::foundation.users.edit
62 18
                'uses' => 'UsersController@edit',
63 18
            ]);
64
65 24
            $this->put('{user_id}/update', [
66 24
                'as'   => 'update',        // auth::foundation.users.update
67 18
                'uses' => 'UsersController@update',
68 18
            ]);
69
70 24
            $this->put('{user_id}/activate', [
71 24
                'as'   => 'activate',      // auth::foundation.users.activate
72 18
                'uses' => 'UsersController@activate',
73 18
            ]);
74
75 24
            $this->put('{user_id}/restore', [
76 24
                'as'   => 'restore',       // auth::foundation.users.restore
77 18
                'uses' => 'UsersController@restore',
78 18
            ]);
79
80 24
            $this->delete('{user_id}/delete', [
81 24
                'as'   => 'delete',        // auth::foundation.users.delete
82 18
                'uses' => 'UsersController@delete',
83 18
            ]);
84 24
        });
85
86 24
        $router->bind('user_id', function($hashedId) {
87
            return User::firstHashedOrFail($hashedId);
88 24
        });
89 24
    }
90
}
91