My Laeavel 5.8 -> query:
Table id int AUTO_INCREMENT
group_id int
coeff_id int
coeff VARCHAR(255)
$guery= DB::table('posts')
->select(DB::raw('count(*) as count, group_id'))
->groupBy('group_id')
->get()->toArray();
I get just below.
Array
(
[0] => stdClass Object
(
[count] => 5
[group_id] => 1
)
[1] => stdClass Object
(
[count] => 5
[group_id] => 2
)
But i want get some thing like below
Array
(
[0] => stdClass Object
(
[count] => 5
[group_id] => 1
[coeff_id]=> 1
[coef] => 0.005
)
[1] => stdClass Object
(
[count] => 5
[group_id] => 2
[coeff_id]=> 2
[coef] => 0.005
)