Adding data to charts using query builder
So i want to make a chart using laravel charts and i want to use my own data from database. As far as i can tell there is no example on how to do it with query builder, only eloquent.
So i want to pass this information, the labels is going to be get from 'test_suites' table and from 'name' column. the data is going to be retrieved from 'test_cases' table in which already connected with id. and i want to count how many cases each suite has. I executed this and i get an error where it says it cannot count a string where it supposed to be a collection. Do i need to use join to get the information on the values or what?
$total_test = DB::table('test_suites')->get();
$labels = [];
$count = [];
$values = DB::table('test_cases')->get();
foreach ($values as $item) {
array_push($count,$item->name->count());
}
return Chartisan::build()
->labels($labels)
->dataset('Sample', $count);
Please or to participate in this conversation.