欢迎各位兄弟 发布技术文章
这里的技术是共享的
On the Form thing, you need to do something like:
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 ran into an issue when using a subdomain route with a ressource controller: Route::group(array('domain' => 'api.example.{tld}'), function()
{
Route::resource('game', 'GameController');
});
When making the GET request for a single ressource with ID 1 ( api.example.test/game/1 ) the Game::find($id) throws a ModelNotFoundException always. I finally found out, that the $id parameter within my GameController::show() Method had value 'test'. It seems as if the value catched from the domain name within the {tld} expression is provided as a parameter for this method by the laravel framework. I am new to Laravel / Laravel 4, so I really hope, that this is not a mistake I made. |
The parameters are passed in from left to right (or outer to inner). Your ID parameter will be the second parameter of your method. |
Thanks a lot for your information. Maybe this would be something to point out within the L4 documentation at http://four.laravel.com/docs/routing#sub-domain-routing to clearify things, as the example somehow didn't show this use case of domain routing. For me it seemed as if the parameter from the subdomain is available within the route closures only. |
PhiloNL commented on Apr 6 2013
I'm having trouble posting data when using subdomain routes and a resource controller.
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:
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!