Looking for proper JOIN syntax in given Paginate for SUM of related records

I’m not sure if you have to use leftJoin while you use earlier ‘contain’