@neilcarpenter give this a try:
Course::with('bookings')
->withCount(['bookings' => function($query) {
$query->select(DB::raw('SUM(bookings.quantity)'));
}])
->whereHas('bookings', function($query) {
$query->where('bookings.status', 'paid');
})
->havingRaw('bookings_count > courses.attendee_limit')
->get()
To get the difference on how many are left, you can then do, bookings_count - attendee_limit.