weixin_39854923
weixin_39854923
2020-12-28 06:28

external routes

Hi, I'm trying to load a separate routes file.

I've tried loading them from my own provider.


        $routeFile = base_path('/Modules/Test/Routes/web.php');
        event(new LoadRouteFile($routeFile));
        if ($routeFile && file_exists($routeFile)) {
            include $routeFile;
        }

and


if (\CoasterCms\Helpers\Cms\Install::isComplete()) {

    include __DIR__ . '/routes/admin.php';
    include __DIR__ . '/routes/cms.php';

    include base_path('/Modules/Test/Routes/web.php');

} else {

I know the routes are there because artisan route:list is showing them.

Every time I try to hit my page I get redirected back to the admin area. (I'm exploring and testing through the admin area).

if I comment out


// Route::any($adminUrl . '{other}', 'CoasterCms\Http\Controllers\AdminController')->where('other', '.*');

I get a 404 page.

Basically my routes file looks like:


$routeNamePrefix = 'coaster.admin.';
$adminUrl = config('coaster::admin.url') . '/';
// $adminController = '';
$nameSpace = 'Modules\Test\Http\Controllers';


Route::group(['prefix' => $adminUrl, 'middleware' => ['web', 'coaster.admin']], function () use ($adminUrl, $routeNamePrefix, $nameSpace) {

    Route::get('test', ['uses' => $nameSpace . '\TestController', 'as' => $routeNamePrefix . 'system']);

});

My routes do work if I add them directly to the admin.php routes file.


$nameSpaceCore = 'Modules\Test\Http\Controllers';
Route::group(['prefix' => $adminUrl, 'middleware' => ['web', 'coaster.admin']], function () use ($adminUrl, $routeNamePrefix, $nameSpaceCore) {

    Route::get('test', ['uses' => $nameSpaceCore . '\TestController', 'as' => $routeNamePrefix . 'system']);

});

But I really don't want to be editing your package routes like this.

I must be missing something, could you give me an idea or a heads up where to look next?

Thanks!

该提问来源于开源项目:CoasterCms/coastercms

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

8条回答

为你推荐

换一换