@hudsonpereira
Thanks for the reply, your example helped me get the records that I needed from the table. I tweaked your query to:
$posts = Post::with(
array(
'postChannels' => function($query){
$q->where('is_main', '=', 1);
}
)
)
->where('status', '=', 1)
->take(2)
->get();
I think my problem was not clear above so I edited it and wanted to know if this is the right approach? Thanks again!
Hm, try this:
$posts = Post::with(
array(
'postChannels' => function($query){
$q->where('is_main', '=', 1);
}
)
)
->where('status', '=', 1)
->postChannels()
->take(2)
->get();
@gpluess Thanks man! I'll try that to see what difference it'll make because the tweaked query that I posted above gives me the records that I need.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community