$list=Order::query() ->select('id','order_no') ->with([ 'orderLogs'=>function($query){ $query->select('id','order_id')->orderByDesc('id'); } ]) ->limit(3) ->get(); $list->each(function ($item){ $item->newOrderLogs=$item->orderLogs->take(2); });
标签:laravel,function,查询,item,query,列表,id,select From: https://www.cnblogs.com/CanyingV/p/17206411.html