0

How can I change Laravel page render url to this format.

http://exampel.com/articles?page=1

to

http://exampel.com/articles/page/1
Morteza Negahi
  • 3,305
  • 8
  • 24
  • 42
  • this might help http://stackoverflow.com/questions/20974404/laravel-pagination-pretty-url – usrNotFound Oct 27 '16 at 14:40
  • @CannotFindSymbol Why When This is possible with Htaccess I use custom codes ? :| – Morteza Negahi Oct 27 '16 at 14:47
  • 1
    Here is something that might interest you (server configuration to redirect ) http://stackoverflow.com/questions/871511/301-redirecting-urls-based-on-get-variables-in-htaccess. Now sure how you wanna implement it though – usrNotFound Oct 27 '16 at 15:12

1 Answers1

-1

You should implement pagination by yourself or use the included one

Here is the docs

Or the simple implementation

you should specify your route, get result from database (or wherever you want), than slice the result array

Route::get('articles/page/{id}', function ($id) {
    $articles = Article::all(); 
    $count = 15; //how many items per page
    //of course you should check if $id is not < 0 etc... 
    return view()->with([
        'articles' => array_slice($articles, $id*$count, $count)
   ])
});
ArtemSky
  • 1,173
  • 11
  • 20