Building an answer to simones. You can do this by doing basically two queries.
$query = DB::table('events')->join('attendees', 'events.id', '=', 'attendees.event_id'); $raised = $query->sum( 'total_raised' ); $hours = $query->sum( 'total_hours' );
It depends on situation. If it were on the administrator / CMS side, I would be inclined to this decision. If it is at the front end, this should be done in a single request, which will be faster. Depending on the content, this may or may not be a significant difference.
$result = DB::table('events')->join('attendees', 'events.id', '=', 'attendees.event_id') ->get( array( DB::raw( 'SUM(attendees.total_raised) AS raised' ), DB::raw( 'SUM(attendees.total_hours) AS hours' ), ));
source share