This is my api which is testing in Postman. It returns value but not pagination value.
http://localhost/api/v1/projects-data //This is api
here is the image of data which its return to Postman

I put the route code in api.php
Route::get('all-blogs', 'Api\ApiController@getBlogs');
And at last in my ApiController.php
public function getBlogs(Request $request, Blog $blog = null)
{
if ($blog != null) {
$blog = Blog::with(['tag', 'comments', 'user'])->where('slug_en', $blog->slug_en)->firstOrFail();
$blog->increment('views');
return response()->json(BlogResource::make($blog));
}
$blogs = Blog::with([
'tag', 'comments', 'user',
])->orderBy('created_at', 'desc')->paginate(5);
return response()->json(BlogResource::collection($blogs));
}
And code on BlogResource.php
public function toArray($request)
{
return [
'id'=>$this->blog_id,
'keyword' => $this->keyword,
'description' => $this->description,
'title' => $this->title,
'content' => $this->content,
'content_bare' => strip_tags($this->content, 'ul,li,ol,p,br,h1,h2,h3,h4,h5,h6,b,a,span,table,thead,tr,th,td,tfoot,tbody,i,em,strong,strike'),
'image_url' => $this->image_url,
'slug' => $this->slug_en,
'views' => $this->views,
'created_at' => date('d M Y', strtotime($this->created_at)),
'ago' => $this->created_at->diffForHumans(),
'comments' => $this->whenLoaded('comments'),
'user' => $this->whenLoaded('user'),
'tag' => $this->whenLoaded('tag'),
];
}
Every Thing working when i put paginate(5). it's return 5 data in Postman. But Not return other information like current_page , first_page and so on is not showing.
I need this type of output return
