3 months ago

Select last column value in join table

Posted 3 months ago by timtom


Do you know how to select the last column value on a joined column with eloquent. I do somehting like that but i get the first column value :

->selectRaw( 'settlements.*, partners.name as partner_name, SUM(payments.amount) as total_paid, payments.date as last_date_paid, IF(SUM(payments.amount) >= settlements.amount, 1, 0) as is_paid' )

I got 3 payments in payments table (one line per payment), and i would like to select the most recent date.

Thanks in advance

Please sign in or create an account to participate in this conversation.