I have a route defined as:
Route::domain('{subdomain}.' . config('app.domain'))->group(function () {
Route::get('/some-url/{id}', function ($id) {
return $id;
});
});
When defining my routes, I utilize a domain parameter {subdomain} to capture the subdomain. However, upon accessing a URL like https://subdomain.example.com/some-url/1, I notice that the $id parameter in the closure contains the value of the subdomain (subdomain) instead of the intended ID (1). To address this issue, I must explicitly define both $subdomain and $id as parameters in the closure:
Route::domain('{subdomain}.' . config('app.domain'))->group(function () {
Route::get('/some-url/{id}', function ($subdomain, $id) {
return $id;
});
});
By defining both parameters, I can accurately access the $id value. However, this approach becomes cumbersome when the subdomain parameter is unnecessary for all routes, complicating the closure signature unnecessarily.
Is there a more concise or efficient method to access route parameters without requiring them as dependencies in the closure functions?
$request->route()->parameter(...)currentTenantas it is multi-tenant application. I just don't need subdomain parameter in Controllers, hence I do not pass these as dependency to controllers. But I need to pass bothsubdomainandidin controller dependency even if I want onlyidin controller logic.