I have been working on a multi-tenant app and I'm trying to set up the routes in sub-domains according to the documentation:https://laravel.com/docs/5.7/routing#route-group-sub-domain-routing
In my web.php route file, I have something like this:
Route::domain('{account}.example.test')->group(function () {
Route::get('/home', 'HomeController@index')->name('home');
});
Right now, the problem is using named routes in blade, but I suppose I may run into the same problem eventually in my Controllers.
Whenever I try to used a named route like this:
Blade Code
<a href="{{ route('home') }}">Home</a>
I get the following error:
Missing required parameters for [Route: home] [URI: home]. (View: /home/vagrant/Code/example/resources/views/example.blade.php)
I have found a way for solving this, you just have to:
<a href="{{ route('home', request('account')) }}">Home</a>
I also "solved" this using a helper...
if (! function_exists('acctRoute')) {
function acctRoute($name = '')
{
return route( $name, request('account'));
}
}
So I can use it like:
<a href="{{ acctRoute('home') }}">Home</a>
But I'm still wondering if there's a cleaner way to do this, maybe with some middleware that always injects the parameter?