UsersRoutes::map()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 47

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 31
CRAP Score 2.0008

Importance

Changes 0
Metric Value
dl 0
loc 47
ccs 31
cts 33
cp 0.9394
rs 9.1563
c 0
b 0
f 0
cc 2
nc 1
nop 0
crap 2.0008
1
<?php namespace Arcanesoft\Auth\Http\Routes\Admin;
2
3
use Arcanedev\Support\Routing\RouteRegistrar;
4
5
/**
6
 * Class     UsersRoutes
7
 *
8
 * @package  Arcanesoft\Auth\Http\Routes\Admin
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class UsersRoutes extends RouteRegistrar
12
{
13
    /* -----------------------------------------------------------------
14
     |  Main Methods
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Register the bindings.
20
     */
21 15
    public static function bindings()
22
    {
23 15
        $registrar = new static;
24
25 15
        $registrar->bind('auth_user', function($hashedId) {
26
            return call_user_func([config('auth.providers.users.model'), 'firstHashedOrFail'], $hashedId);
27 15
        });
28 15
    }
29
30
    /**
31
     * Map routes.
32
     */
33
    public function map()
34
    {
35 15
        $this->prefix('users')->name('users.')->group(function () {
36 15
            $this->get('/', 'UsersController@index')
37 15
                 ->name('index'); // admin::auth.users.index
38
39 15
            $this->get('trash', 'UsersController@trashList')
40 15
                 ->name('trash'); // admin::auth.users.trash
41
42 15
            $this->get('roles-filter/{auth_role}', 'UsersController@listByRole')
43 15
                 ->name('roles-filter.index'); // admin::auth.users.roles-filter.index
44
45 15
            $this->get('create', 'UsersController@create')
46 15
                 ->name('create'); // admin::auth.users.create
47
48 15
            $this->post('store', 'UsersController@store')
49 15
                 ->name('store'); // admin::auth.users.store
50
51 15
            $this->prefix('{auth_user}')->group(function () {
52 15
                $this->get('/', 'UsersController@show')
53 15
                     ->name('show'); // admin::auth.users.show
54
55 15
                $this->get('edit', 'UsersController@edit')
56 15
                     ->name('edit'); // admin::auth.users.edit
57
58 15
                $this->put('update', 'UsersController@update')
59 15
                     ->name('update'); // admin::auth.users.update
60
61 15
                $this->put('activate', 'UsersController@activate')
62 15
                     ->middleware('ajax')
63 15
                     ->name('activate'); // admin::auth.users.activate
64
65 15
                $this->put('restore', 'UsersController@restore')
66 15
                     ->middleware('ajax')
67 15
                     ->name('restore'); // admin::auth.users.restore
68
69 15
                $this->delete('delete', 'UsersController@delete')
70 15
                     ->middleware('ajax')
71 15
                     ->name('delete'); // admin::auth.users.delete
72
73 15
                if (impersonator()->isEnabled()) {
74
                    $this->get('impersonate', 'UsersController@impersonate')
75
                         ->name('impersonate'); // admin::auth.users.impersonate
76
                }
77 15
            });
78 15
        });
79 15
    }
80
}
81