Issue
I'm actually using nwidart/laravel-modules on Laravel 5.8 and I got problem with some routes.
I created some modules (module_1, module_2, module_3).
Each module has file web.php, and in these files, I added these lines:
module_1 web.php:
Route::domain('module1.domain.com')->group(function(){
Route::get('/', 'ModuleOneController@index')->name('home');
});
module_2 web.php:
Route::domain('module2.domain.com')->group(function(){
Route::get('/', 'ModuleTwoController@index')->name('home');
});
module_3 web.php:
Route::domain('module3.domain.com')->group(function(){
Route::get('/', 'ModuleThreeController@index')->name('home');
});
And in my main web.php in laravel project:
Route::domain('domain.com')->group(function(){
Route::get('/', 'HomeController@index')->name('home');
});
I can access to these urls and each controllers are called on each subdomains, but when I want to call the function route('home')
, it always returns https://module3.domain.com event if I specified each route names in different domain.
I would to get:
route('home')
=> 'https://module1.domain.com'
when I call it in module1.domain.com
route('home')
=> 'https://module2.domain.com'
when I call it in module2.domain.com
etc...
Is there a way to call the same route name in different domain and get differents results ?
Thank in advance
Solution
Route::group(['domain' => 'module.domain.com'], function (){
Route::post('login', [
'as' => 'login',
'uses' => 'AuthController@login'
]);
// ... all route
});
Route::group(['domain' => 'module1.domain.com'], function (){
// ... all route
});
Answered By - Nick
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.