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

PermissionsRoutes::map()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 1.0013

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 16
cts 18
cp 0.8889
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
crap 1.0013
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
     * Map routes.
21
     */
22 12
    public function map()
23
    {
24
        $this->bind('auth_permission', function($hashedId) {
25
            return Permission::firstHashedOrFail($hashedId);
26 12
        });
27
28
        $this->bind('auth_permissions_group', function($hashedId) {
29
            return PermissionsGroup::firstHashedOrFail($hashedId);
30 12
        });
31
32
        $this->prefix('permissions')->name('permissions.')->group(function () {
33 12
            $this->get('/', 'PermissionsController@index')
34 12
                 ->name('index'); // admin::auth.permissions.index
35
36 12
            $this->get('group/{auth_permissions_group}', 'PermissionsController@group')
37 12
                 ->name('group'); // admin::auth.permissions.group
38
39 12
            $this->prefix('{auth_permission}')->group(function () {
40 12
                $this->get('/', 'PermissionsController@show')
41 12
                     ->name('show'); // admin::auth.permissions.show
42
43 12
                $this->middleware('ajax')
44 12
                     ->delete('roles/{auth_role}/detach', 'PermissionsController@detachRole')
45 12
                     ->name('roles.detach'); // admin::auth.permissions.roles.detach
46 12
            });
47 12
        });
48 12
    }
49
}
50