V
V
Vasyl Fomin2017-02-06 16:23:13
Laravel
Vasyl Fomin, 2017-02-06 16:23:13

How to pull all active articles and their active reviews (where the status is 1)?

There are two tables posts && reviews, the tables are respectively connected: one to many. Each table has a field status (0 || 1)
I know how to pull all active articles (posts) and for each article all reviews (reviews):
Post::where('status', 1)->with('reviews')->get();
But I need to pull all active articles and their reviews in which the status is also 1
. is it possible to write such a query using eloquent and how to do it right?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question