Completed
Pull Request — master (#11)
by
unknown
01:41
created

RouteServiceProvider::mapMicroboardRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace Microboard\Providers;
4
5
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
6
use Illuminate\Support\Facades\File;
7
use Illuminate\Support\Facades\Route;
8
use Laravel\Ui\AuthRouteMethods;
9
use Microboard\Http\Middleware\Localization;
10
11
class RouteServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * This namespace is applied to your controller routes.
15
     *
16
     * In addition, it is set as the URL generator's root namespace.
17
     *
18
     * @var string
19
     */
20
    protected $namespace = 'Microboard\Http\Controllers';
21
22
    /**
23
     * Define the routes for the application.
24
     *
25
     * @return void
26
     */
27
    public function map()
28
    {
29
        $this->mapApiRoutes();
30
31
        $this->mapWebRoutes();
32
33
        if (File::exists(base_path('routes/microboard.php'))) {
34
            $this->mapMicroboardRoutes();
35
        }
36
    }
37
38
    /**
39
     * Define the "web" routes for the application.
40
     *
41
     * These routes all receive session state, CSRF protection, etc.
42
     *
43
     * @return void
44
     */
45
    protected function mapWebRoutes()
46
    {
47
        Route::prefix(config('microboard.routes.prefix', 'admin'))
48
            ->middleware(['web', Localization::class])
49
            ->namespace($this->namespace)
50
            ->group(__DIR__ . '/../../routes/web.php');
51
    }
52
53
    /**
54
     * Define the "Microboard" routes for the application.
55
     *
56
     * These routes all receive session state, CSRF protection, etc.
57
     *
58
     * @return void
59
     */
60
    protected function mapMicroboardRoutes()
61
    {
62
        Route::prefix(config('microboard.routes.prefix', 'admin'))
63
            ->middleware(array_merge(['web', Localization::class], config('microboard.routes.middleware', [])))
64
            ->name('microboard.')
65
            ->namespace(
66
                config('microboard.routes.namespace.base', 'Admin') . '\\' .
67
                config('microboard.routes.namespace.admin_directory', 'Admin')
68
            )
69
            ->group(base_path('routes/microboard.php'));
70
    }
71
72
    /**
73
     * Define the "api" routes for the application.
74
     *
75
     * These routes are typically stateless.
76
     *
77
     * @return void
78
     */
79
    protected function mapApiRoutes()
80
    {
81
        Route::prefix(config('microboard.routes.prefix', 'admin') . '/api')
82
            ->middleware(config('microboard.routes.apiMiddleware', []))
83
            ->name('microboard.api.')
84
            ->namespace($this->namespace)
85
            ->group(__DIR__ . '/../../routes/api.php');
86
    }
87
88
    public function register()
89
    {
90
        Route::mixin(new AuthRouteMethods);
91
    }
92
}
93