I have these tables:
places
id
name
address
users
id
name
email
reviews
id
place_id
user_id
title
review
as_anoniem
The user_id
is filled even if as_anoniem
is 1
.
Now I want to have all the reviews
for all the places
with the user
except for the ones with as_anoniem = 1
.
Something like this:
Place::with(['review' => function ($query) {
return $query->with('user')->where('as_anoniem', 1);
}]);
This is not fully correct as it returns only reviews
with as_anoniem = 1
.
How can I achieve this using eloquent?