Completed
Push — master ( e43e24...a5d827 )
by ARCANEDEV
05:31
created

RouteServiceProvider::getFoundationRouteGroup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanesoft\Auth\Providers;
2
3
use Arcanesoft\Core\Bases\RouteServiceProvider as ServiceProvider;
4
use Arcanesoft\Auth\Http\Routes;
5
use Illuminate\Routing\Router;
6
7
/**
8
 * Class     RouteServiceProvider
9
 *
10
 * @package  Arcanesoft\Auth\Providers
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class RouteServiceProvider extends ServiceProvider
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Getters & Setters
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Get the routes namespace
21
     *
22
     * @return string
23
     */
24
    protected function getRouteNamespace()
25
    {
26
        return 'Arcanesoft\\Auth\\Http\\Routes';
27
    }
28
29
    /**
30
     * Get the auth foundation route prefix.
31
     *
32
     * @return string
33
     */
34 18
    public function getFoundationAuthPrefix()
35
    {
36 18
        $prefix = array_get($this->getFoundationRouteGroup(), 'prefix', 'dashboard');
37
38
        return "$prefix/" . config('arcanesoft.auth.route.prefix', 'authorization');
39
    }
40
41
    /* ------------------------------------------------------------------------------------------------
42
     |  Main Functions
43
     | ------------------------------------------------------------------------------------------------
44 18
     */
45
    /**
46 18
     * Define the routes for the application.
47
     *
48 18
     * @param  Router $router
49
     */
50
    public function map(Router $router)
51
    {
52
        $this->mapPublicRoutes($router);
53
        $this->mapFoundationRoutes($router);
54
    }
55
56
    /**
57
     * Define the public routes for the application.
58
     *
59
     * @param  Router  $router
60 18
     */
61
    private function mapPublicRoutes(Router $router)
62 18
    {
63 18
        $router->group([
64 18
            'prefix'    => 'auth',
65
            'as'        => 'auth::',
66
            'namespace' => 'Arcanesoft\\Auth\\Http\\Controllers\\Front',
67
        ], function ($router) {
68
            (new Routes\Front\AuthenticateRoutes)->map($router);
69
            (new Routes\Front\RegisterRoutes)->map($router);
70
            (new Routes\Front\ReminderRoutes)->map($router);
71 18
        });
72
    }
73 18
74 18
    /**
75 18
     * Define the foundation routes for the application.
76 18
     *
77
     * @param  Router  $router
78 18
     */
79 18
    private function mapFoundationRoutes(Router $router)
80 18
    {
81 18
        $attributes = array_merge($this->getFoundationRouteGroup(), [
82 18
            'as'        => 'auth::foundation.',
83
            'namespace' => 'Arcanesoft\\Auth\\Http\\Controllers\\Foundation',
84
        ]);
85
86
        $router->group($attributes, function (Router $router) {
87
            (new Routes\Foundation\ProfileRoutes)->map($router);
88
        });
89 18
90
        $router->group(array_merge(
91 18
            $attributes,
92 18
            ['prefix' => $this->getFoundationAuthPrefix()]
93 18
        ), function (Router $router) {
94 18
            (new Routes\Foundation\StatsRoutes)->map($router);
95
            (new Routes\Foundation\UsersRoutes)->map($router);
96
            (new Routes\Foundation\RolesRoutes)->map($router);
97 18
            (new Routes\Foundation\PermissionsRoutes)->map($router);
98 18
        });
99
    }
100
}
101