I have a query that i’m writed to fetch data
with last_sent_at as (
Select offer_id, lead_id, max(created_at) as sent_at
From offer_history
Group by offer_id, lead_id)
I need to join it with laravel model system.
So i have three tables: leads => history => offers
I have request
Lead::with([..., 'offers'])->someFunction(?)->filters()->get();
And i need to fetch data from ‘last_sent_at’ but i dont understand how to do it.
Im tried subQuery, but it works wert slow