$productList = Product::where(
function ($query) {
$query->where('is_status', 1);
}
)
->whereNull('errors')
->with(['user'])
->whereHas(
'user',
function ($query) {
$query->where('is_authenticated', 1);
$query->whereNotNull('username');
$query->whereNotNull('password');
}
)
->get()
->take(10);
Здесь я хочу добавить $query->whereNotNull('balance');
ниже $query->whereNotNull('password');
, если цена соответствующего продукта превышает 500. Пожалуйста, посмотрите, что я хочу произвести
$productList = Product::where(
function ($query) {
$query->where('is_status', 1);
}
)
->whereNull('errors')
->with(['user'])
->whereHas(
'user',
function ($query) {
$query->where('is_authenticated', 1);
$query->whereNotNull('username');
$query->whereNotNull('password');
if({PRICE_OF_PRODUCT} > 500) {
$query->whereNotNull('balance');
}
}
)
->get()
->take(10);