Level 75
For which reason?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
any help, change a given eloquent query to database query
$exchangeRate = Currency::where('currencyType', 'USD')->firstOrFail()->exchangeRate;
// change $organizations to database query
$organizations = Organization::withCount(['rooms','confrences'])->with(['typeOfOrganization','user'])
->where('approved', 1)->when(request('type_of_organization'), function($query){ return $query->where('organizations.type_of_organization_id', request('type_of_organization')); })
->when($request->has(['start_price', 'end_price']), function ($query) use ($request, $exchangeRate) {
return $query->where(function ($query) use ($request) {
$query->whereBetween('avg_price', [
$request->start_price, $request->end_price
])->where('currency_id', 1);
})->orWhere(function ($query) use ($request, $exchangeRate) {
$query->whereBetween('avg_price', [
$request->start_price * $exchangeRate, $request->end_price * $exchangeRate
])->where('currency_id', 2);
});
})->get();
thanks in advance
Please or to participate in this conversation.