laravel列表查询时,限制关联数据的数量
$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); });