Paginator $elements variable access
I am using VueJs in my front-end, stumbled upon pagination and noticed something after I published the paginator.
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="uk-disabled"><span>{{ $element }}</span></li>
@endif
Notice that the $elements variable that is the responsible for the mysterious elipsis ... in the pagination buttons, I dug in the classes associated with the Paginator class and saw that $elements variable is only available in the view that called the Paginator instance ie.
$things = Model::paginate();
In my case, I created an api that returns only the Paginator instance to be accessed via ajax, and because of that I lost my access to the magical $elements variable. Is there any chance that they include it the the Paginator instance's json response for easy access? Right now I edited
Illuminate\Pagination\LengthAwarePaginator.php's public method toArray and added
'elements` => $this->elements()
I know changing files in the vendor is not good. Can you think of another valid way to do this? TIA
Please or to participate in this conversation.