I have an error when paging the data, just load the first page and then give me a MethodNotAllowedHttpException .
I've been spinning around and I can not solve it.
Route:
Route::post('estados/resultado','consultasController@searchestado')->name('consultas.estado.search');
Controller:
public function searchestado (Request $request){
$consulta = Order::Estado($request->state, $request->orden, $request->modo)->paginate(5);
return view('resultadoConsulta')->with('order',$consulta);
}
Scope:
public function scopeEstado($query,$estado,$orden,$modo){
return $query->where('state','=',$estado)
->where('user_id','=',\Auth::user()->id)
->orderBy($orden,$modo);
}
Loading everything without paging works well , try paging in the socope and I also did not work properly.
I load the values indicated in paginate (5) and the navigation between pages is rendered correctly but the contents of the other pages are not loaded.
I leave a DD in the controller before returning the data to the view:
I have other pages that work correctly, I am relatively new with this framework and there is something I am missing, I have consulted the documentation but I can not solve it.
Maybe it should not be with POST because when I add the? page = 2 it generates the error?
Try GET and it did not work either, when changing pages, the parameters of the query were deleted.
POST URL:
/consultas/estados/resultado
/consultas/estados/resultado?page=2
GET URL:
/consultas/estados/resultado?state=En+Camino&orden=buy_date&modo=desc
/consultas/estados/resultado?page=2