Generate data in key/value structure / For ex: for admin panel dashboard
download :
https://gist.github.com/saeedvir/330e894045baa8e6a37ba34b8ad7c407
$dataGenerator = new DataStructureGenerator('data', true,true);
$dataGenerator->setData('users', 8);
$dataGenerator->setData('payments', 8000);
# laravel ex:
$dataGenerator->setDataFromModel(new \App\User, function ($model) {
return $model->select('id')->count();
}, 'users', 8000);
$dataGenerator->setKeyFunctions(
[
'payments' => function ($value) {
return number_format($value);
},
]
);
print_r($dataGenerator->getJsonData(true);
print_r($dataGenerator->getJsonData(false, ['users']));