[{
"productname" : "product 1",
"label" :["used license", "unused license"],
"value" : [16,15]
},
{
"productname" : "product 2",
"label" :["used license", "unused license"],
"value" : [16,15]
}]
I am trying to create the above format from laravel code.But there were no success so far. In the above code label is the names of two columns and value are the values of two columns.
My code so far is below
$licenses_count = products::select('product_name AS
productname','total_license', 'license_remaining')
->get();
return $licenses_count;
my code output
[{
"productname" : "product 1",
"total_licenses" :5,
"remaining_licenses" : 11,
},
{
"productname" : "product 2",
"total_licenses" :16,
"remaining_licenses" : 15,
}]
Any help would be appreciated.