This code:
$users = Users::with(['posts' => function($post) use ($request) {
$post->where('votes', '>', 100);
}])->get();
dd($users->toArray());
Return output like this:
0 => [
"user_id" => 1
"posts" => []
]
What can I do to return an empty array of users? I tried to do like this:
$users = Users::with(['posts'])
->where('posts.votes', '>', 100)->get();
dd($users->toArray());
But got an error:
Undefined table: 7 ERROR: issing FROM-clause entry for table "posts"