Prova detta:
$rateEruToDolor =2;
$rateAedToDolor =3;
$products = Product::join('product_options', 'products.id', '=', 'product_options.product_id')
->join('options', 'product_options.option_id', '=', 'options.id')
->selectRaw('price, currency, IF(currency=0, price * ?, IF(currency=1, price * ?, price))
as dolor_price', [$rateEruToDolor, $rateAedToDolor]);
$products->orderBy('dolor_price');
dd($products->get()->toArray());
Lista alla fält i din produkt-/alternativtabell tillsammans med price
och currency
redan listad i selectRaw('xxx, xxx, price, currency, IF ...)
metod ovan. Hoppas detta hjälper