mercredi 22 juillet 2020

Where to put pagination logic in MVC

I am confused as to where the pagination logic belongs in MVC such as

  • Generating the limit and offset results - this should ideally be done in the model, where model is where all database queries are.
  • Generating metadata (next_page, last_page, total) - not sure

The framework I am currently using, laravel, uses a .paginate method on a query instance like:

DB::table('users')->paginate();

The paginate method is called from a query builder instance and returns the database results along with the page metadata. I am confused because this seems to do many things at once.

so the core of my question is: where should we put pagination logic in MVC?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire