Reputation: 604
How can I do this in laravel eloquent, i tried doing this but It gives me error.. how can I sum two columns in laravel SUM( column1 + column2 )
FileDBConsistency::join('Servers', 'Servers.srv_id', '=' , 'FileDBConsistency.srv_id')
->sum('SUM( FileDBConsistency.dbconflict + FileDBConsistency.fileconflict ) as sum')
->get( $array )
Upvotes: 0
Views: 6520
Reputation: 25384
I see two issues:
get()
the results of a sum()
operation.DB::raw()
.Here's a Tinker example from the database I have open:
[1] > Priority::sum(DB::raw('priority + priority'));
// '2768'
Upvotes: 3