Completed
Push — master ( 1d96a4...49a6f0 )
by ARCANEDEV
04:17
created

RouteServiceProvider::mapPublicRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

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