Completed
Push — master ( cb5a9c...81e444 )
by ARCANEDEV
03:29
created

RouteServiceProvider::getFoundationAuthPrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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