这不是我第一次在laravel中使用路由参数,但是我似乎无法使其工作。
路线:
Route::group(['prefix' => 'admin', 'before' => 'auth|beta|admin'], function()
{
Route::post('remove/{$id}', ['uses' => 'AdminController@postRemoveID', 'as' => 'admin.postremoveid']);
});
控制器:
public function postRemoveID($id)
{
$remove = ServiceProvider::where('id','=',$id)->first();
$remove->delete();
return Redirect::route('admin.manage'); //This just redirects to the page the user is currently on
}
刀片:
<a href="{{ route('admin.postremoveid', $id) }}">
<i class="fa fa-times"></i>
</a>
什么会导致我的网站重定向到404?
感谢您的帮助!! -Patrick
答案 0 :(得分:2)
你不需要外卡上的$
Route::group(['prefix' => 'admin', 'before' => 'auth|beta|admin'], function()
{
Route::post('remove/{id}', ['uses' => 'AdminController@postRemoveID', 'as' => 'admin.postremoveid']);
});
答案 1 :(得分:2)
使用Route:get();
Route::get('remove/{id}', ['uses' => 'AdminController@getRemoveID', 'as' => 'admin.postremoveid']);
控制器:
public function getRemoveID($id)
{
$remove = ServiceProvider::where('id','=',$id)->first();
$remove->delete();
return Redirect::route('admin.manage'); //This just redirects to the page the user is currently on
}