I am working with laravel API resource. when we don't use any resource collection we get pagination links etc with paginate(10). but when i use Resource::collection i get nothing, just the fields i put in resource.
This is my Controller
return response()->json([
"items" => LatestProjectsResource::collection(Project::has('pages')->where('type', $type)->latest()->paginate(20))
]);
And this is my Resource
public function toArray($request)
{
return [
'id' => $this->id,
'title' => $this->name,
'slug' => $this->slug,
'url' => $this->url,
'thumbnail' => new ThumbnailResource($this->thumbnail),
];
}
Result
I tried some answers from online community including this Customising Laravel 5.5 Api Resource Collection pagination one but its not working
I tried $this->collection
but no luck
Please help me out here.