Laravel MethodNotAllowedHttpException

时间:2017-10-03 07:32:27

标签: php laravel laravel-5

当我点击它们时,我想要删除权限角色,所以我做了一个带有角色ID和权限ID的路由

Route::post('management/role-permission/{role_id}/{permission_id}', 'RolePermissionsController@Delete');

我从我的html链接获取此路线:

 @foreach($data as $dat)
                <div class="col-xs-3 text-center">
                    <form  action="/management/role-permission/{{$role->id}}/{{$dat->id}}" method="POST">
                        {!! csrf_field() !!}
                        {{method_field('DELETE')}}
                        <button onclick="return confirm('Are you sure?')"  class="btn turquoiseButton btn-margin full-width"><i class='fa fa-close close-btn'></i> {{$dat->name}} </button>
                    </form>
                </div>

@endforeach

路线转到这个控制器:

 public function Delete( $role_id ,$permission_id)
{
    $role_permission=DB::table('permission_role')
        ->where('role_id' ,$role_id)
        ->where('permission_id' ,$permission_id)
        ->delete();
    return Redirect::to('/management/role-permission/'.$role_id . '/list');
}

但我一直无缘无故地得到这个错误

  

MethodNotAllowedHttpException

1 个答案:

答案 0 :(得分:2)

更改

Route::post('management/role-permission/{role_id}/{permission_id}', 'RolePermissionsController@Delete');

Route::delete('management/role-permission/{role_id}/{permission_id}', 'RolePermissionsController@Delete');