• File: AccountCollection.php
  • Full Path: /var/www/html/back/app/Collections/AccountCollection.php
  • File size: 819 bytes
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace App\Collections;

use App\Http\Resources\AccountResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;

class AccountCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @return array<int|string, mixed>
     */
    public function toArray($request)
    {

        return [
            'current_page' => $this->currentPage(),
            'data' => AccountResource::collection($this->collection),
            'first_page_url' => $this->url(1),
            'from' => $this->currentPage(),
            'to' => $this->lastItem(),
            'prev_page_url' => $this->previousPageUrl(),
            'next_page_url' => $this->nextPageUrl(),
            'per_page' => $this->perPage(),
        ];
    }
}