Completed
Pull Request — master (#24)
by ARCANEDEV
02:09
created

UsersRoutes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 90.24%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 70
c 4
b 0
f 0
ccs 37
cts 41
cp 0.9024
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A bindings() 0 8 1
A map() 0 47 2
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 12
    public static function bindings()
22
    {
23 12
        $registrar = new static;
24
25 6
        $registrar->bind('auth_user', function($hashedId) {
26
            return call_user_func([config('auth.providers.users.model'), 'firstHashedOrFail'], $hashedId);
27 12
        });
28 12
    }
29
30
    /**
31
     * Map routes.
32
     */
33 6
    public function map()
34
    {
35 6
        $this->prefix('users')->name('users.')->group(function () {
36 12
            $this->get('/', 'UsersController@index')
37 12
                 ->name('index'); // admin::auth.users.index
38
39 12
            $this->get('trash', 'UsersController@trashList')
40 12
                 ->name('trash'); // admin::auth.users.trash
41
42 12
            $this->get('roles-filter/{auth_role}', 'UsersController@listByRole')
43 12
                 ->name('roles-filter.index'); // admin::auth.users.roles-filter.index
44
45 12
            $this->get('create', 'UsersController@create')
46 12
                 ->name('create'); // admin::auth.users.create
47
48 12
            $this->post('store', 'UsersController@store')
49 12
                 ->name('store'); // admin::auth.users.store
50
51 12
            $this->prefix('{auth_user}')->group(function () {
52 12
                $this->get('/', 'UsersController@show')
53 12
                     ->name('show'); // admin::auth.users.show
54
55 12
                $this->get('edit', 'UsersController@edit')
56 12
                     ->name('edit'); // admin::auth.users.edit
57
58 12
                $this->put('update', 'UsersController@update')
59 12
                     ->name('update'); // admin::auth.users.update
60
61 12
                $this->put('activate', 'UsersController@activate')
62 12
                     ->middleware('ajax')
63 12
                     ->name('activate'); // admin::auth.users.activate
64
65 12
                $this->put('restore', 'UsersController@restore')
66 12
                     ->middleware('ajax')
67 12
                     ->name('restore'); // admin::auth.users.restore
68
69 12
                $this->delete('delete', 'UsersController@delete')
70 12
                     ->middleware('ajax')
71 12
                     ->name('delete'); // admin::auth.users.delete
72
73 12
                if (impersonator()->isEnabled()) {
74
                    $this->get('impersonate', 'UsersController@impersonate')
75
                         ->name('impersonate'); // admin::auth.users.impersonate
76
                }
77 12
            });
78 6
        });
79 6
    }
80
}
81