Support the ongoing development of →
posted 3 years ago
Last updated 1 year ago.

Use whereHas and whereDoesntHave Please mark this thread as solved it that works for you


@Hrvoje Jukic, my laravel version is 5.1 and can you explain little bit how will it return 0 if there is no data in a month!


WhereHas will allow you to fetch only the records having/missing payments.

If you don't want it in the where section, but in the select you should use withCount.


Hrvoje Jukic. It did not meet my requirement, it returning the same result as i am getting.. i will explain little bit more to you: Result I am getting from that query: { payment_amount: 5000, month:1 }, { payment_amount: 4500, month:3 }, { payment_amount: 5500, month:5 }

The result i am expecting: { payment_amount: 5000, month:1 }, { payment_amount: 0, month:2 }, { payment_amount: 4500, month:3 }, { payment_amount: 0, month:4 }, { payment_amount: 5500, month:5 }


Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.