You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
user_center/app/Http/Resources/BaseCollection.php

35 lines
923 B

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class BaseCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'data' => $this->collection,
'links' => [
'path' => $this->path(),
"first"=> $this->url(1),
"last"=> $this->url($this->lastPage()),
"prev"=> $this->previousPageUrl(),
"next"=> $this->nextPageUrl()
],
'meta' => [
"current_page"=> $this->currentPage(),
"last_page"=> $this->lastPage(),
'per_page' => $this->perPage(),
"total"=> $this->total()
],
];
}
}