M
M
Mykola Ivashchuk2018-11-19 16:44:28
Laravel
Mykola Ivashchuk, 2018-11-19 16:44:28

How to get model page in pagination?

How to find her page as a result of pagination having model id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2018-11-19
@mykolaim

It seems to me that the standard pagination of the model is not suitable
for this. First you need to get an array of all IDs for the current request - this is in order not to pull all the models and not take up memory
Then, for example, I would split the array into equal parts (by the number of elements on the page )
Then I sorted through these parts and checked for the presence of the desired ID in each portion, in fact, when the portion of the desired ID is in the portion, the page will be the current iteration index

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question