2
我web.php
看起来像子域的路由名称
Route::group(
[
'domain' => '{tenant}.' . config('app.url'),
],
function() {
$this->get('/', '[email protected]')->name('home');
}
);
我HomeController
看起来像
/**
* Show the application dashboard.
*
* @param $tenant
* @return \Illuminate\Http\Response
*/
public function index($tenant)
{
return view('home', compact('tenant'));
}
在app.blade.php
文件看起来像
<a href="{{ route('home', ['tenant', $tenant]) }}">home</a>
使用我们在子域路由在我们的时候每次都会传递通配符{tenant}
SE route()
否则它会弹出这个错误
(3/3) ErrorException
Missing required parameters for [Route: home] [URI: home].
这是多余的遍布controller
以及blade
文件。有没有什么解决方案可以默认绑定{wildcard}
?
我应该在哪里定义呢? –
将此功能添加到您使用作曲者加载的文件中。作曲家的例子:' ''autoload“:{”files“:[”path/to/file“]}'。 –
你的意思是像辅助函数一样使用这种方法吗? –