我正面临一个大墙的幼虫路线,我似乎无法找到解决方案
我在视图模板中有这个表单
<form url="/request/{{$equipment->url}}" method="POST"> <div class="row"> <div class="col-sm-4"> <div class="mt10">Start Date:</div> <input type="date" required name="starting_date" value="" placeholder="From" class="request-input request-date mb10"> </div> <div class="col-sm-4"> <div class="mt10">End Date:</div> <input type="date" required name="ending_date" value="" placeholder="To" class="request-input request-date mb10"> </div> <div class="col-sm-4"> <div class="mt10">Quantity</div> <input type="number" required name="quantity" value="" placeholder="Quantity" class="request-input mb10"> </div> </div> <div class="row"> <div class="col-sm-4"> <div class="mt10">Voltage</div> <input type="number" required name="voltage" value="" placeholder="Voltage" class="request-input mb10"> </div> <div class="col-sm-4"> <div class="mt10">Param 1</div> <input type="text" required name="param_1" value="" placeholder="Parameter" class="request-input mb10"> </div> <div class="col-sm-4"> <div class="mt10">Param 2</div> <input type="text" required name="param_2" value="" placeholder="Parameter" class="request-input mb10"> </div> </div> <div class="row"> <div class="col-sm-12"> <button class="btn btn-block button-orange">Get quotes now</button> </div> </div> </form>
这是相应的路线
Route::group([ 'middleware' => 'rental'],function(){ Route::get('/my-requests/{readby_url}','PagesController@requests'); Route::post('/request/{equipment_url}','PagesController@request'); Route::post('/request/create','RequestsController@create'); Route::post('/request/accept','RequestsController@accept'); });
我的问题是使用Route :: post(‘/ request / {equipment_url}’,’PagesController @ request’);
因为当方法设置为post时似乎不接受url参数.
即它会引发错误
MethodNotAllowedHttpException in RouteCollection.PHP line 201: in RouteCollection.PHP line 201 at RouteCollection->methodNotAllowed(array('GET','HEAD')) in RouteCollection.PHP line 188 at RouteCollection->getRouteForMethods(object(Request),array('GET','HEAD')) in RouteCollection.PHP line 140 at RouteCollection->match(object(Request)) in Router.PHP line 746 at Router->findRoute(object(Request)) in Router.PHP line 655 at Router->dispatchToRoute(object(Request)) in Router.PHP line 631 at Router->dispatch(object(Request)) in Kernel.PHP line 237
我想传递一个参数并同时发布数据.
有没有办法让这项工作?我被告知Route :: post也处理GET,但它似乎不起作用.
这个问题与Laravel无关
<form url="/request/{{$equipment->url}}" method="POST">
用行动取代网址
<form action="/request/{{$equipment->url}}" method="POST">