Completed
Push — master ( 394917...1d96a4 )
by ARCANEDEV
08:06
created

RouteServiceProvider::mapFoundationRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 22
ccs 17
cts 17
cp 1
rs 9.2
cc 1
eloc 15
nc 1
nop 1
crap 1
1
<?php namespace Arcanesoft\Auth\Providers;
2
3
use Arcanedev\Support\Providers\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 foundation route prefix.
31
     *
32
     * @return string
33
     */
34 18
    protected function getFoundationPrefix()
35
    {
36 18
        return config('arcanesoft.foundation.route.prefix', 'dashboard');
37
    }
38
39
    /**
40
     * Get the auth foundation route prefix.
41
     *
42
     * @return string
43
     */
44 18
    public function getFoundationAuthPrefix()
45
    {
46 18
        return $this->getFoundationPrefix() . '/' . config('arcanesoft.auth.route.prefix', 'authorization');
47
    }
48
49
    /* ------------------------------------------------------------------------------------------------
50
     |  Main Functions
51
     | ------------------------------------------------------------------------------------------------
52
     */
53
    /**
54
     * Define the routes for the application.
55
     *
56
     * @param  Router $router
57
     */
58 18
    public function map(Router $router)
59
    {
60 18
        $this->mapPublicRoutes($router);
61 18
        $this->mapFoundationRoutes($router);
62 18
    }
63
64
    /**
65
     * Define the public routes for the application.
66
     *
67
     * @param  Router  $router
68
     */
69 18
    private function mapPublicRoutes(Router $router)
70
    {
71 18
        $router->group([
72 18
            'prefix'    => 'auth',
73 18
            'as'        => 'auth::',
74 18
            'namespace' => 'Arcanesoft\\Auth\\Http\\Controllers\\Front',
75
        ], function ($router) {
76 18
            (new Routes\Front\AuthenticateRoutes)->map($router);
77 18
            (new Routes\Front\RegisterRoutes)->map($router);
78 18
            (new Routes\Front\ReminderRoutes)->map($router);
79 18
        });
80 18
    }
81
82
    /**
83
     * Define the foundation routes for the application.
84
     *
85
     * @param  Router  $router
86
     */
87 18
    private function mapFoundationRoutes(Router $router)
88
    {
89
        $attributes = [
90 18
            'prefix'    => $this->getFoundationPrefix(),
91 18
            'as'        => 'auth::foundation.',
92 18
            'namespace' => 'Arcanesoft\\Auth\\Http\\Controllers\\Foundation',
93 18
        ];
94
95
        $router->group($attributes, function (Router $router) {
96 18
            (new Routes\Foundation\ProfileRoutes)->map($router);
97 18
        });
98
99 18
        $router->group(array_merge(
100 18
            $attributes,
101 18
            ['prefix' => $this->getFoundationAuthPrefix()]
102 18
        ), function (Router $router) {
103 18
            (new Routes\Foundation\StatsRoutes)->map($router);
104 18
            (new Routes\Foundation\UsersRoutes)->map($router);
105 18
            (new Routes\Foundation\RolesRoutes)->map($router);
106 18
            (new Routes\Foundation\PermissionsRoutes)->map($router);
107 18
        });
108 18
    }
109
}
110