use AppModelsUser;
$users = User::with(['posts' => function ($query) {
$query->where('title', 'like', '%code%');
}])->get();
# Select columns
Post::query()
->with(['user' => function($query) {
$query->select('id','username');
}])
->get();