Completed
Push — master ( caab36...1437d7 )
by ARCANEDEV
02:59
created

RouteServiceProvider::getRouteNamespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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 24
        $router->group([
64 24
            'prefix'    => 'auth',
65 18
            'as'        => 'auth::',
66 18
            'namespace' => 'Arcanesoft\\Auth\\Http\\Controllers\\Front',
67
        ], function ($router) {
68 24
            (new Routes\Front\AuthenticateRoutes)->map($router);
69 24
            (new Routes\Front\RegisterRoutes)->map($router);
70 24
            (new Routes\Front\ReminderRoutes)->map($router);
71 24
        });
72 24
    }
73
74
    /**
75
     * Define the foundation routes for the application.
76
     *
77
     * @param  Router  $router
78
     */
79 24
    private function mapFoundationRoutes(Router $router)
80
    {
81 24
        $attributes = array_merge($this->getFoundationRouteGroup(), [
82 24
            'as'        => 'auth::foundation.',
83 18
            'namespace' => 'Arcanesoft\\Auth\\Http\\Controllers\\Foundation',
84 18
        ]);
85
86
        $router->group($attributes, function (Router $router) {
87 24
            (new Routes\Foundation\ProfileRoutes)->map($router);
88 24
        });
89
90 24
        $router->group(array_merge(
91 18
            $attributes,
92 24
            ['prefix' => $this->getFoundationAuthPrefix()]
93 24
        ), function (Router $router) {
94 24
            (new Routes\Foundation\StatsRoutes)->map($router);
95 24
            (new Routes\Foundation\UsersRoutes)->map($router);
96 24
            (new Routes\Foundation\RolesRoutes)->map($router);
97 24
            (new Routes\Foundation\PermissionsRoutes)->map($router);
98 24
        });
99 24
    }
100
}
101