Am trying to produce a json object ouput of the following
{
name: 'creditor',
y: 5600
},
{
name: 'Supplier',
y: 2400,
},
In my php i have
public function getTotalInspected($ts1, $ts2){
$inspectiondata = [];
$truck_categories = TblTruckSubtypes::find()->all();
foreach ($truck_categories as $truck_category) {
$name = $truck_category["description"];
$trucks = TblTrucks::find()->
where(['truck_category'=>$truck_category["id"]])->count();
$inspectiondata[] = ["name"=>$name,'y'=> $trucks];
}
return $inspectiondata;
}
The above produces an output of the form
{
"name": 'creditor',
"y": 5600
},
{
"name": 'Supplier',
"y": 2400,
},
Note the name from the desired output and "name" in the output.
How can i get the desired output above.