Попытка
$questions=TheQuestion::paginate(5);
return $this->successResponce(TheQuestionResource::collection($questions),'','');
{
success: true,data: [{},{},{},{},{}],tag: "",message: ""
}
public function successResponce($data,$tag,$message)
{
return response()->json([
'success' => true,
'data' => $data,
'tag'=>$tag,
'message' => $message,
]);
}
Ресурс API работает нормально, но данные нумерации страниц, такие как current_page, total ... не отображаются. Но при возвращении без JSON ответа все приходит
$questions=TheQuestion::paginate(5);
return TheQuestionResource::collection($questions);
{
data: [],
links: {
first: "http://localhost:8000/api/v1/admin/question/management/show/%7B%7D?page=1",
last: "http://localhost:8000/api/v1/admin/question/management/show/%7B%7D?page=3",
prev: null,
next: "http://localhost:8000/api/v1/admin/question/management/show/%7B%7D?page=2"
},
meta: {
current_page: 1,
from: 1,
last_page: 3,
path: "http://localhost:8000/api/v1/admin/question/management/show/%7B%7D",
per_page: 5,
to: 5,
total: 11
}
}