I am trying to get the values of koh, kih etc specifically in this SQL Query below
$afterhours = $this->electricityConnections->select(\DB::raw('SUM(kwh_used_out_of_hours) as koh'),
(\DB::raw('SUM(kwh_used_in_hours) as kih')), (\DB::raw('SUM(cost_out_of_hours) as coh')),
(\DB::raw('SUM(cost_in_hours) as cih')))
->from('after_hours_yesterday_category')
->where('category_id', '=', 11)
->where('building_id', '=', 52)
->get();
return $afterhours;
I did this in other to get them
$afterhours = $this->electricityConnections->select(\DB::raw('SUM(kwh_used_out_of_hours) as koh'),
(\DB::raw('SUM(kwh_used_in_hours) as kih')), (\DB::raw('SUM(cost_out_of_hours) as coh')),
(\DB::raw('SUM(cost_in_hours) as cih')))
->from('after_hours_yesterday_category')
->where('category_id', '=', 11)
->where('building_id', '=', 52)
->get();
dd($afterhours->koh);
and i got this error "message": "Property [koh] does not exist on this collection instance.", .
What am i doing wrong?
When i dd($afterhours) only i get this
#attributes: array:4 [
"koh" => "440.59"
"kih" => "773.74"
"coh" => "67.64"
"cih" => "129.52"
]