Level 63
Have you tried to add the pagination datas by customizing the QuestionResource ?
I have this eloquent to return data as API
public function index()
{
$questions = $this->questions()
->when(request('search'), function ($query) {
return $query->where('title', 'LIKE','%'.\request('search').'%');
})
->latest()->paginate(2);
$categories = Category::select('id', 'name')->get();
return [
'data' => QuestionResource::collection($questions),
'categories' => CategoryResource::collection($categories),
];
}
the problem is it's not showing pagination data, (links, meta).
when I return data directly without an array I got data
return QuestionResource::collection($questions);
Please or to participate in this conversation.