Reputation: 1066
I have an action named destroy in UserController I don't wanna work this action instead of UserInfoController@destroy supposed to run. So I need to redirect to the UserInfoControlle@destroy
controller.
UserController@destroy action;
return redirect()->action(
'UserInfoController@destroy',['id' => 1]
);
Action successfully ran but I get this error;
The GET method is not supported for this route. Supported methods: POST.
Upvotes: 1
Views: 98
Reputation: 1239
you have some way to do that like below:
make new get
route for that
Route::get('/delete/{id}','UserInfoController@destroy')->name('deleteWithGetMethod');
change post
to any
in your route
Route::any('/delete/{id}','UserInfoController@destroy')->name('delete');
return a view that contains below code
<form id="myForm" action="{{ route('delete',$userInfoId) }}" method="post">
</form>
<script type="text/javascript">
document.getElementById('myForm').submit();
</script>
Upvotes: 1