helo here I have JSON data. I made it in the helper based on the day of the month and year. here I make an attendance data report, and this is the JSON
{
"data": {
"user": {
"id_user": "13",
"name": "JHON"
},
"month": "01",
"year": "2021",
"attendace": [
{
"date": "01-01-2021",
"in": "07:24:50",
"out": "17:03:42"
},
{
"date": "03-01-2021",
"in": "07:08:50",
"out": "17:18:50"
},
{
"date": "07-01-2021",
"in": "07:03:42",
"out": "18:03:42"
}
],
"day": [
{
"day": "Friday",
"date": "01-01-2021"
},
{
"day": "Saturday",
"date": "02-01-2021"
},
{
"day": "Sunday",
"date": "03-01-2021"
},
{
"day": "Monday",
"date": "04-01-2021"
},
......
...... // to
{
"day": "Sunday",
"date": "31-01-2021"
}
]
}
}
the question is how to combine JSON absent with JSON day? and I want to make it like this, if the absent data is blank on date 5,6,7,8 then it is automatically null
I want to like this
"day": [
{
"day": "Friday",
"date": "01-01-2021"
"data" [
{
"in": "07:03:42",
"out": "18:03:42"
}
]
},
{
"day": "Saturday",
"date": "02-01-2021"
"data" [
{
"in": null,
"out": null
}
]
},
{
"day": "Sunday",
"date": "03-01-2021"
"data" [
{
"in": "07:03:42",
"out": "18:03:42"
}
]
},
]
and this my code
pulic function get(){
$data['user'] = $this->mymodel->find($id_user);
$data['bulan'] = $bulan;
$data['tahun'] = $tahun;
$data['attendance'] = $this->mymodel->get_absen($id_user, $bulan, $tahun);
$data['day'] = hari_bulan($bulan, $tahun);
$message = array(
'status' => true,
'data' => $data
);
$this->response($message, REST_Controller::HTTP_OK);
}