Мой столик о весе. Например,
(February 10, 2020) = 60kg
(February 11, 2020) = 62kg
(February 11, 2020) = 63kg
(February 11, 2020) = 64kg
(February 12, 2020) = 65kg
Json должен возвращаться,
{
"weight": 60,
"created_at": "2020-02-10"
},
{
"weight": 63,
"created_at": "2020-02-11"
},
{
"weight": 65,
"created_at": "2020-02-12"
}
с нумерацией страниц.
Вот мой существующий код без среднего.
public function weightChart(Request $request, $id)
{
$data = WeightHistory::where('user_id', $id)->orderBy('created_at', 'DESC')->paginate(7);
return WeightChartResource::collection($data);
}