i have something data like this json data
my problem is, how to set children to null if there is no data children.
>Solution :
Try this
$data[] = [
'id' => $men->id,
'title' => $men->title,
'icon' => $men->icon,
'children' => (count($men->menuchild) > 0) ? $men->menuchild: null,
];