dimanche 27 janvier 2019

Laravel 5.7 Pagination Pretty URL

I want create a pagination for post controller, this is my route:

Route::get('post/{page?}' , 'PostController@Test');

And my action:

public function Test($page = 1)
{
    $tests = Test::paginate(15, ['*'], 'page', $page);

    foreach ($tests as $test) {
        echo $test->id;
    }

    echo $tests->render();
}

now i can go to http://127.0.0.1:8000/post/2 to open page 2, but my pagination url is like http://test.com/post?page=2

can i fix this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire