Completed
Push — master ( 720025...0e57e6 )
by ARCANEDEV
04:07
created

PermissionsRoutes::map()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1.0016

Importance

Changes 0
Metric Value
dl 0
loc 26
c 0
b 0
f 0
ccs 15
cts 17
cp 0.8824
rs 8.8571
cc 1
eloc 15
nc 1
nop 1
crap 1.0016
1
<?php namespace Arcanesoft\Auth\Http\Routes\Admin;
2
3
use Arcanedev\Support\Bases\RouteRegister;
4
use Arcanesoft\Auth\Models\Permission;
5
use Arcanesoft\Auth\Models\PermissionsGroup;
6
use Illuminate\Contracts\Routing\Registrar;
7
8
/**
9
 * Class     PermissionsRoutes
10
 *
11
 * @package  Arcanesoft\Auth\Http\Routes\Admin
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
class PermissionsRoutes extends RouteRegister
15
{
16
    /* ------------------------------------------------------------------------------------------------
17
     |  Main Functions
18
     | ------------------------------------------------------------------------------------------------
19
     */
20
    /**
21
     * Map routes.
22
     *
23
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
24
     */
25 12
    public function map(Registrar $router)
26
    {
27
        $this->bind('auth_permission', function($hashedId) {
28
            return Permission::firstHashedOrFail($hashedId);
29 12
        });
30
31
        $this->bind('auth_permissions_group', function($hashedId) {
32
            return PermissionsGroup::firstHashedOrFail($hashedId);
33 12
        });
34
35
        $this->group(['prefix' => 'permissions', 'as' => 'permissions.'], function () {
36 12
            $this->get('/', 'PermissionsController@index')
37 12
                 ->name('index'); // admin::auth.permissions.index
38
39 12
            $this->get('group/{auth_permissions_group}', 'PermissionsController@group')
40 12
                 ->name('group'); // admin::auth.permissions.group
41
42 12
            $this->group(['prefix' => '{auth_permission}'], function () {
43 12
                $this->get('/', 'PermissionsController@show')
44 12
                     ->name('show'); // admin::auth.permissions.show
45
46 12
                $this->delete('roles/{auth_role}/detach', 'PermissionsController@detachRole')
47 12
                     ->name('roles.detach'); // admin::auth.permissions.roles.detach
48 12
            });
49 12
        });
50 12
    }
51
}
52