ApiPaginator.php 828 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Tools;
  3. use Illuminate\Pagination\LengthAwarePaginator;
  4. class ApiPaginator extends LengthAwarePaginator
  5. {
  6. public function toArray()
  7. {
  8. return [
  9. 'current_page' => $this->currentPage(),
  10. 'data' => $this->items->toArray(),
  11. 'first_page_url' => $this->url(1),
  12. 'from' => $this->firstItem(),
  13. 'last_page' => $this->lastPage(),
  14. 'last_page_url' => $this->url($this->lastPage()),
  15. // 'links' => $this->linkCollection()->toArray(),
  16. 'next_page_url' => $this->nextPageUrl(),
  17. 'path' => $this->path(),
  18. 'per_page' => $this->perPage(),
  19. 'prev_page_url' => $this->previousPageUrl(),
  20. 'to' => $this->lastItem(),
  21. 'total' => $this->total(),
  22. ];
  23. }
  24. }