My name is jeff My name is jeff - 11 months ago 199
PHP Question

Laravel MethodNotAllowedHttpException

I have Permission Roles that i want to delete when i click on them so i did a route that takes role id and permission id

Route::post('management/role-permission/{role_id}/{permission_id}', '[email protected]');


And i get this route from link from my 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


And the route goes to this controller :

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');
}


But i keep getting this error for no reason


MethodNotAllowedHttpException

Answer Source

Change

Route::post('management/role-permission/{role_id}/{permission_id}', '[email protected]');

To

Route::delete('management/role-permission/{role_id}/{permission_id}', '[email protected]');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download