pavlen's avatar

Laravel 5 paggination problem

Hi all,

I have problem with my pagination :

Controller code:

 $pagination = Orders::latest()->paginate(2);
 return view('orders.index',compact('pagination'));

View code:

{!! str_replace('/?', '?', $pagination->render()) !!}

All data have been loaded on page,that is fine,also pagination is on bottom, but when click on page 2, get error:

MethodNotAllowedHttpException in compiled.php line 7717

Tnx

0 likes
8 replies
taijuten's avatar

Not sure, but this looks like it could be a routing issue.

Is it possible that one of your routes is picking up /page-2 as a url parameter, thinking it's an order id?

If so, make sure that this route is above the one catching this.

pavlen's avatar

Hmm,

my route for this page is Route:post is that maybe problem ?

pmall's avatar

When you click on a link like the navigation, it send a GET request. So you have to define the GET route.

pavlen's avatar

Can i have POST and GET route for same page?

This is my post route:

Route::post('filter_unique',['as' => 'post_date', 'uses' => 'FilterController@GetUniqueDate']);

pmall's avatar

I guess you are doing some kind of search page filtering the list according to post parameters.

Well, it wont work as the navigation link are GET request, so the post parameters wont be transmitted. You have to define only one GET route and do the filtering with the url query parameter instead of post values. Then you use the append() method of the paginator to add these parameters to the url.

scorlink's avatar

try to use "Route::any" instead of "Route::post"

1 like

Please or to participate in this conversation.