在我route.php我有:Laravel 4:資源控制與前綴
Route::group(array('prefix'=>'admin'),function(){
Route::resource('products','AdminProductsController');
});
但是,當我做STORE
函數,它是一個POST,它拋出一個MethodNotAllowedHttpException
,但它運作良好,對所有GET
功能。我的表格action
的價值是{{ URL::to('admin/products/store') }}
。
AdminProductsController.php位於controller/admin
目錄中。
請幫忙。
控制器:
<?php
class AdminProductsController extends BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return 'Yow';
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$url = URL::to('admin/products/store');
return<<<qaz
<form method="post" action="{$url}">
<input type="hidden" name="hehehe" value="dfsgg" />
<input type="submit" />
</form>
qaz;
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
return 'whahaha';
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
return $id;
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
return $id;
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}
我想你有一個錯字,不應該是:Route :: resource('products','AdminProductsController');'? – msturdy
你能分享控制器中的代碼嗎?專門針對你提到的'store'行爲? – msturdy
請再次檢查 – Orvyl