laravel with closure

$product = $product->where('uuid', $uuid)->firstOrFail();

$affiliators = $affiliator->with([
'affiliatorProducts' => function($query) use($product) {

$query->where('product_id', $product->id);
}])

->orderBy('id', 'desc')
->paginate($pageSize, null, null, $currentPage);

猜你喜欢

转载自www.cnblogs.com/fengliang/p/9167140.html