<?php
namespace App\Http\Resources\User;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
class UserPaginatedResource extends ResourceCollection
{
public static $wrap = 'data';
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
/**
* Get any additional data that should be returned with the resource array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function with($request)
{
return [
'meta' => [
'page_name' => $this->resource->getPageName()
],
'application' => [
"name" => env('APP_NAME'),
"version" => "1.0",
"release" => "2",
],
'response' => [
'time' => number_format(microtime(true) - LARAVEL_START, 3).'s',
"datetime" => now(),
"timestamp" => now()->timestamp,
"status" => "SUCCESS",
"code" => 200,
"message" => "OK",
]
];
}
}
Created
October 11, 2019 05:40
-
-
Save ManojKiranA/01ee755fcb815fb1d77be055fd0f2a94 to your computer and use it in GitHub Desktop.
Laravel Api Recource
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment