Modify Paginate in Laravel 5.8

Asked

Viewed 51 times

-2

Good night, you guys! I’m developing a tool using Laravel. Maybe I still have to study more to reach a level of knowledge to be able to discuss it better, because I’m not a developer, but thank God I’ve learned everything I need to be able to do what I need.

My only question is: - How can I change the number of pages displayed in a table? Currently my pages display tables with the standard of 10 items. I would like to change this pattern, change from 10 items to 30 for easy user experience.

To help clarify my doubt, follow the image below inserir a descrição da imagem aqui

I know that each one’s time is precious, if you can maybe point out some links or give me a hint of how I can follow... I really appreciate it! Thank you!

  • welcome! tries to follow these steps to make your question clearer to everyone here. read carefully https://pt.meta.stackoverflow.com/questions/5483/manual-de-como-n%C3%83Object-questions? cb=1 hope the answer I put below helps.

1 answer

1


To change the amount to be displayed create a variable in your controller

protected $totalPaginas = 30;

then an example could be your index page, which I I suppose that could bring all the results of the consulted return.

public function index()
    {
        $varParaEnviarParaView = $this->minhaModelFiltrada->paginate($this->totalPaginas);
        return view('caminho.para.minha.view', compact("varParaEnviarParaView"));
    }

the paginate method returns the number of pages.

last in your view add to the bottom of the page, out of the foreach

{{$varParaEnviarParaView->links()}}

I believe it solves the question.

  • Andre! I don’t know how to thank you... Thank you for the guidance in sending me the good practice link with the questions, I am new here and I apologize if I made a mistake. But you understood my doubt, even gave me everything of "hand kissed" and it worked here. Gosh, thank you very much! Success, may God bless.

  • I’m glad it worked out! ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.