I'm having trouble posting data when using subdomain routes and a resource controller.
Route::group(array('domain' => '{subdomain}.' . Config::get('app.domain')), function()
{
//Resources
Route::resource('project', 'ProjectsController');
});
// Adding this resolves the issue
// Route::resource('project', 'ProjectsController');
When I try to set the action of my form to the store method:
{{ Form::open(array('action' => 'ProjectsController@store')) }}
I get the following error:
_MissingMandatoryParametersException: Some mandatory parameters are missing ("subdomain") to generate a URL for route "project.store"._
Also another issue when redirecting:
return Redirect::action('ProjectsController@show', array('1')); // Error (see below)
return Redirect::action('ProjectsController@show', array('mysubdomain', '1')); // Works, when manually passing the subdomain, but is this required?
_InvalidParameterException: Parameter "project" for route "project.show" must match "[^/]++" ("" given) to generate a corresponding URL._
Adding the subdomain as extra parameter to the form does not resolve the issue.
Any idea what the problem could be?
Thanks!
On the Form thing, you need to do something like:
Form::open(['action' => ['ProjectsController@store', 'subdomain', '1']]);
As far as passing the sub-domain, yes, that is currently required since it is a wildcard parameter. We can try to come up with some kind of helper there that uses the current domain if one is not specified, but I will have to look into it.
I have the same issue.
Route::domain('{organization}.site.dev')->middleware([ 'auth' , 'organization'])->group(function(){
Route::get('dashboard', 'HomeController@index')->name('dashboard');
});
Currently, I need to add the $organization parameter everytime I use the route helper. Else, it will throw Missing required parameters exception
<a href="{{ route('dashboard',[ 'organization' => $organization ]) }}">
Is there a way to just call:
<a href="{{ route('dashboard') }}">
since it's inside the Route::domain group?
Thanks!
I am interested in this issue. I have the same problem. Can we make the route method works if creating a wild card sub domain route?
we still have this issue. it doesn't really make sense to treat domain arguments like route arguments.
+1
I'm new to Laravel.
I was like " 馃槂 " when I discovered Sub-domain routing functionnality ! And " 馃あ " when I faced this issue... :)
So +1 ^^
+1
+1
This solution worked for me: https://developerjack.com/blog/2018/laravel-resource-and-subdomain-routes/
Basically sets a default parameter value using the URL facade.
Most helpful comment
I have the same issue.
Currently, I need to add the
$organizationparameter everytime I use theroutehelper. Else, it will throwMissing required parametersexception<a href="{{ route('dashboard',[ 'organization' => $organization ]) }}">Is there a way to just call:
<a href="{{ route('dashboard') }}">since it's inside the
Route::domaingroup?Thanks!