Commit 497ab143 authored by huy.dang's avatar huy.dang

fix route:cache issue

parent 6a34661b
......@@ -4,7 +4,6 @@ namespace Modules\Core\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Routing\Router;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
abstract class RoutingServiceProvider extends ServiceProvider
{
......@@ -52,15 +51,18 @@ abstract class RoutingServiceProvider extends ServiceProvider
$this->loadApiRoutes($router);
});
$prefixes = array_merge(json_decode(setting('core::locales')), ['']);
foreach ($prefixes as $prefix) {
$router->group([
'namespace' => $this->namespace,
'prefix' => LaravelLocalization::setLocale(),
'prefix' => $prefix,
'middleware' => ['localizationRedirect', 'web'],
], function (Router $router) {
$this->loadBackendRoutes($router);
$this->loadFrontendRoutes($router);
});
}
}
/**
* @param Router $router
......
......@@ -3,10 +3,6 @@
use Illuminate\Routing\Router;
/** @var Router $router */
$router->bind('media', function ($id) {
return app(\Modules\Media\Repositories\FileRepository::class)->find($id);
});
$router->group(['prefix' => '/media'], function (Router $router) {
$router->get('media', [
'as' => 'admin.media.media.index',
......
......@@ -58,6 +58,10 @@ class MediaServiceProvider extends ServiceProvider
BuildingSidebar::class,
$this->getSidebarClassForModule('media', RegisterMediaSidebar::class)
);
app('router')->bind('media', function ($id) {
return app(FileRepository::class)->find($id);
});
}
public function boot(DispatcherContract $events)
......
......@@ -3,13 +3,6 @@
use Illuminate\Routing\Router;
/** @var Router $router */
$router->bind('menu', function ($id) {
return app(\Modules\Menu\Repositories\MenuRepository::class)->find($id);
});
$router->bind('menuitem', function ($id) {
return app(\Modules\Menu\Repositories\MenuItemRepository::class)->find($id);
});
$router->group(['prefix' => '/menu'], function (Router $router) {
$router->get('menus', [
'as' => 'admin.menu.menu.index',
......
......@@ -47,6 +47,13 @@ class MenuServiceProvider extends ServiceProvider
BuildingSidebar::class,
$this->getSidebarClassForModule('menu', RegisterMenuSidebar::class)
);
app('router')->bind('menu', function ($id) {
return app(MenuRepository::class)->find($id);
});
app('router')->bind('menuitem', function ($id) {
return app(MenuItemRepository::class)->find($id);
});
}
/**
......
......@@ -3,10 +3,6 @@
use Illuminate\Routing\Router;
/** @var Router $router */
$router->bind('page', function ($id) {
return app(\Modules\Page\Repositories\PageRepository::class)->find($id);
});
$router->group(['prefix' => '/page'], function (Router $router) {
$router->get('pages', [
'as' => 'admin.page.page.index',
......
......@@ -3,15 +3,13 @@
use Illuminate\Routing\Router;
/** @var Router $router */
if (! App::runningInConsole()) {
$router->get('/', [
$router->get('/', [
'uses' => 'PublicController@homepage',
'as' => 'homepage',
'middleware' => config('asgard.page.config.middleware'),
]);
$router->any('{uri}', [
]);
$router->any('{uri}', [
'uses' => 'PublicController@uri',
'as' => 'page',
'middleware' => config('asgard.page.config.middleware'),
])->where('uri', '.*');
}
])->where('uri', '.*');
......@@ -39,6 +39,10 @@ class PageServiceProvider extends ServiceProvider
BuildingSidebar::class,
$this->getSidebarClassForModule('page', RegisterPageSidebar::class)
);
app('router')->bind('page', function ($id) {
return app(PageRepository::class)->find($id);
});
}
public function boot()
......
......@@ -4,9 +4,6 @@ use Illuminate\Routing\Router;
/** @var Router $router */
$router->group(['prefix' => 'tag'], function (Router $router) {
$router->bind('tag__tag', function ($id) {
return app(\Modules\Tag\Repositories\TagRepository::class)->find($id);
});
$router->get('tags', [
'as' => 'admin.tag.tag.index',
'uses' => 'TagController@index',
......
......@@ -41,6 +41,10 @@ class TagServiceProvider extends ServiceProvider
BuildingSidebar::class,
$this->getSidebarClassForModule('tag', RegisterTagSidebar::class)
);
app('router')->bind('tag__tag', function ($id) {
return app(TagRepository::class)->find($id);
});
}
public function boot()
......
......@@ -4,9 +4,6 @@ use Illuminate\Routing\Router;
/** @var Router $router */
$router->group(['prefix' =>'/translation'], function (Router $router) {
$router->bind('translations', function ($id) {
return \Modules\Translation\Entities\TranslationTranslation::find($id);
});
$router->get('translations', [
'uses' => 'TranslationController@index',
'as' => 'admin.translation.translation.index',
......
......@@ -11,6 +11,7 @@ use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;
use Modules\Translation\Console\BuildTranslationsCacheCommand;
use Modules\Translation\Entities\Translation;
use Modules\Translation\Entities\TranslationTranslation;
use Modules\Translation\Events\Handlers\RegisterTranslationSidebar;
use Modules\Translation\Repositories\Cache\CacheTranslationDecorator;
use Modules\Translation\Repositories\Eloquent\EloquentTranslationRepository;
......@@ -45,6 +46,10 @@ class TranslationServiceProvider extends ServiceProvider
BuildingSidebar::class,
$this->getSidebarClassForModule('translation', RegisterTranslationSidebar::class)
);
app('router')->bind('translations', function ($id) {
return TranslationTranslation::find($id);
});
}
public function boot()
......
......@@ -81,9 +81,6 @@ $router->group(['prefix' => '/account'], function (Router $router) {
'as' => 'admin.account.profile.update',
'uses' => 'Account\ProfileController@update',
]);
$router->bind('userTokenId', function ($id) {
return app(\Modules\User\Repositories\UserTokenRepository::class)->find($id);
});
$router->get('api-keys', [
'as' => 'admin.account.api.index',
'uses' => 'Account\ApiKeysController@index',
......
......@@ -66,6 +66,10 @@ class UserServiceProvider extends ServiceProvider
BuildingSidebar::class,
$this->getSidebarClassForModule('user', RegisterUserSidebar::class)
);
app('router')->bind('userTokenId', function ($id) {
return app(UserTokenRepository::class)->find($id);
});
}
/**
......
......@@ -3,13 +3,6 @@
use Illuminate\Routing\Router;
/** @var Router $router */
$router->bind('module', function ($module) {
return app(\Nwidart\Modules\Repository::class)->find($module);
});
$router->bind('theme', function ($theme) {
return app(\Modules\Workshop\Manager\ThemeManager::class)->find($theme);
});
$router->group(['prefix' => '/workshop'],
function (Router $router) {
$router->get('modules', [
......
......@@ -20,6 +20,7 @@ use Modules\Workshop\Scaffold\Module\Generators\ValueObjectGenerator;
use Modules\Workshop\Scaffold\Module\ModuleScaffold;
use Modules\Workshop\Scaffold\Theme\ThemeGeneratorFactory;
use Modules\Workshop\Scaffold\Theme\ThemeScaffold;
use Nwidart\Modules\Repository;
class WorkshopServiceProvider extends ServiceProvider
{
......@@ -45,6 +46,13 @@ class WorkshopServiceProvider extends ServiceProvider
BuildingSidebar::class,
$this->getSidebarClassForModule('workshop', RegisterWorkshopSidebar::class)
);
app('router')->bind('module', function ($module) {
return app(Repository::class)->find($module);
});
app('router')->bind('theme', function ($theme) {
return app(ThemeManager::class)->find($theme);
});
}
public function boot()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment