mehdithemaker's avatar

Pagination MethodNotAllowedHttpException problem

Hello I have 2 views one that make me made a searsh to get the data from db and one that show me that data when I have set pagination with $myobject->links() it's not working and it giving me an error MethodNotAllowedHttpException I have already tryed all solutions on internet it's not working I have opened a question in stackoverflow https://stackoverflow.com/questions/50449928/how-to-fix- methodnotallowedhttpexception-error-pagination-laravel with the views and functions I forgot to add form of research view :

form from first view: https://codepen.io/mehdi-el-aissi/pen/MGLdKm

What i get http://test.oo/resultat and i can see my values and also the pagination but when i click in number 2 in pagination or any number I get the error MethodNotAllowedHttpException and the link change to http://fsjes2.oo/resultat?page=2 as exemple

i'm sorry if I didn't know how to post a good tread i'm a beginer please any idea how to fix that issue?

0 likes
1 reply
Cronix's avatar

HTML links <a>, like the pagination links, perform a get request, so the route must also use a Route::get(). It looks like your route is using Route::post().

So this needs to be a get route

Route::post('/resultat', 'ExamsController@show')->name('show-exams-cne-results');

If you ever get MethodNotAllowedHttpException, that is the reason (sending wrong request type to route that uses different verb)

Please or to participate in this conversation.