public function countVoteStats($count_id) {
$model = self::find($count_id);
return [
'agree' => $model->convVote->sum('agree'),
'disagree' => $model->convVote->sum('disagree'),
'neutral' => $model->convVote->sum('neutral'),
];
}
Или тремя отдельными запросами, зато без загрузки лишних полей и сущностей:
public function countVoteStats($count_id) {
$query = conv_voting::where('conv_id', $count_id);
return [
'agree' => $query->sum('agree'),
'disagree' => $query->sum('disagree'),
'neutral' => $query->sum('neutral'),
];
}