Hello All,
I have a self project. I am trying to create an application that can track my financial status.
So I have an Account table and model. I also have a transactions table and model which is in one to many relationship with account table (One Account has many transactions)
What I want is displaying all accounts with last 3 transactions each. I couldn't figure out how to do it. Could you help me please?
You can't limit eager load for list.
Meybe something like this?
Account::with(
[
'transactions' => function ($comment) {
$comment->where('created_at', '<=', '1999-12-21');
}
]
)->get();
Or you can perform standard query with join to get all (last 3 transaction ids) and inject to with scope
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community