Level 12
@omidwolf You can query your with().
https://laravel.com/docs/10.x/eloquent-relationships#constraining-eager-loads
I need to filter 'example' on $a->load('examples'), is there a way to do this? (even collect and filter)
from:
[{ id:1, title:'a1', examples: [{ id:10, name:'e1', active:1 }, { id:11, name:'e2', active:0 }] }, id:2, title:'a2', examples: [{ id:20, name:'e3', active:1 }, { id:21, name:'e4', active:0 }] }]
to
[{ id:1, title:'a1', examples: [{ id:10, name:'e1', active:1 }] }, id:2, title:'a2', examples: [{ id:20, name:'e3', active:1 }] }]
Please or to participate in this conversation.