Skip to content

Instantly share code, notes, and snippets.

@developerdino
Created September 7, 2017 05:42
Show Gist options
  • Save developerdino/199e12d48143ce95927c7843419af4cb to your computer and use it in GitHub Desktop.
Save developerdino/199e12d48143ce95927c7843419af4cb to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Resources;
use App\Comment;
use App\People;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Collection;
class ArticlesResource extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public function toArray($request)
{
return [
'data' => ArticleResource::collection($this->collection),
];
}
public function with($request)
{
return [
'links' => [
'self' => route('articles.index'),
],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment