Skip to content

Instantly share code, notes, and snippets.

@zgabievi
Created March 29, 2020 08:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zgabievi/3154c5deffa37c0a23a97f93ed0200a9 to your computer and use it in GitHub Desktop.
Save zgabievi/3154c5deffa37c0a23a97f93ed0200a9 to your computer and use it in GitHub Desktop.
Locale + Admin
<?php
Route::get('/', 'DashboardController')->name('dashboard');
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
//
protected $namespace = 'App\Http\Controllers';
//
public const HOME = '/home';
//
public function boot()
{
parent::boot();
}
//
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
$this->mapAdminRoutes();
}
//
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
//
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
//
protected function mapAdminRoutes()
{
Route::prefix('{locale}')
->middleware('locale')
->group(function () {
Route::prefix('admin')
->middleware('admin')
->namespace($this->namespace . '\\Admin')
->group(base_path('routes/admin.php'));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment