0
votes

When creating a new instance of Laravel's Paginator, I know how to use all parameters of it's __construct method, except one. According to the Paginator Laravel API page, it should look like this:

void __construct(mixed $items, int $perPage, int|null $currentPage = null, array $options = [])

I need help with the options parameter. The page says:

Parameters
...   
array    $options    (path, query, fragment, pageName)

What do all these options do and how do I use them? I couldn't find any proper documentation for this, and all information I have is a few examples of other fellow coders on SO using the path element.

1

1 Answers

0
votes

Nothing specifically is using this $options parameter. When you pass this argument it sets $options on the class and it also iterates the $options array and sets the class variables with the names from the keys to the options. So you can use the "options" argument as a way to set some of the properties of the Paginator instance itself when you create one manually. You can also use it as extra data to pass with the Paginator as you have access to these options from getOptions()