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

PermissionsRoutes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 45
c 0
b 0
f 0
ccs 22
cts 24
cp 0.9167
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A bindings() 0 12 1
A map() 0 19 1
1
<?php namespace Arcanesoft\Auth\Http\Routes\Admin;
2
3
use Arcanedev\Support\Routing\RouteRegistrar;
4
use Arcanesoft\Auth\Models\Permission;
5
use Arcanesoft\Auth\Models\PermissionsGroup;
6
7
/**
8
 * Class     PermissionsRoutes
9
 *
10
 * @package  Arcanesoft\Auth\Http\Routes\Admin
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class PermissionsRoutes extends RouteRegistrar
14
{
15
    /* -----------------------------------------------------------------
16
     |  Main Methods
17
     | -----------------------------------------------------------------
18
     */
19
    /**
20
     * Register the bindings.
21
     */
22 12
    public static function bindings()
23
    {
24 12
        $registrar = new static;
25
26 6
        $registrar->bind('auth_permission', function($hashedId) {
27
            return Permission::firstHashedOrFail($hashedId);
28 12
        });
29
30 6
        $registrar->bind('auth_permissions_group', function($hashedId) {
31
            return PermissionsGroup::firstHashedOrFail($hashedId);
32 12
        });
33 12
    }
34
35
    /**
36
     * Map routes.
37
     */
38 6
    public function map()
39
    {
40 6
        $this->prefix('permissions')->name('permissions.')->group(function () {
41 12
            $this->get('/', 'PermissionsController@index')
42 12
                 ->name('index'); // admin::auth.permissions.index
43
44 12
            $this->get('group/{auth_permissions_group}', 'PermissionsController@group')
45 12
                 ->name('group'); // admin::auth.permissions.group
46
47 12
            $this->prefix('{auth_permission}')->group(function () {
48 12
                $this->get('/', 'PermissionsController@show')
49 12
                     ->name('show'); // admin::auth.permissions.show
50
51 12
                $this->delete('roles/{auth_role}/detach', 'PermissionsController@detachRole')
52 12
                     ->middleware('ajax')
53 12
                     ->name('roles.detach'); // admin::auth.permissions.roles.detach
54 12
            });
55 6
        });
56 6
    }
57
}
58