我正在开发一个laravel多租户应用程序,它得到hyn多租户( https://laravel-tenancy.com/ )的支持,如果url是"http://domain.test“,我只想显示我的主页,如果url是laravel5.6中的"http://tenant.domain.test”,则显示用户(租户-每个用户的动态名称)主页。
我试过了
//enter to this group if subdomain is present and show user homepage
Route::domain('{tenant}.domain.test')->group(function () {
Route::get('/', 'HomePage');
Auth::routes();
});
//else show main homepage
Route::domain('domain.test')->group(function () {
Route::get('/', 'HomePage');
});但问题是,需要在每个视图中传递{子域}的值,否则会出现如下错误
缺少路由所需的参数:登录。
发布于 2019-06-26 11:17:50
Route::domain(checkDomain())->group(function () {
Route::get('/', function () {
return "You are on a custom domain";
});
});
Route::get('/', function () {
return "You are on main domain.";
});
public function checkDomain()
{
if (request()->getHttpHost() == 'domain.test') {
return request()->getHttpHost();
}
}https://stackoverflow.com/questions/56771403
复制相似问题