$imageUsersInfos = images::with('User' => function($q){
$q->select('id','phone');
})->where('imageable_type', 'App\User')->get();
//查询一个分类下已经上架的商品,用到了with另一方法
public function category($categoryId)
{
$category = Category::with(['goods'=>function($query){
$query->where('is_sale', 1);
}])->find($categoryId);
return $category;
}