Aronaman
4 months ago
419
4
Laravel

how do i short this

Posted 4 months ago by Aronaman

it is working, but how can i short it with out using merge?

   $exchangeRateToDollar=Currency::where('currencyType','ETB')->firstOrFail()->exchangeRate;
   $startPriceDollar =$request->start_price*$exchangeRateToDollar;
   $endPriceDollar =$request->end_price*$exchangeRateToDollar;


 $organizationsETB = Organization::where('approved', 1)->where('currency_id',1)
 ->when(request(['start_price', 'end_price']), function($query) {
    return $query->where('organizations.avg_price', '>=', request('start_price'))->where('organizations.avg_price', '<=', request('end_price'));
     })->get();



 $organizationsUSD = Organization::where('approved', 1)->where('currency_id',2)
 ->when(request(['start_price', 'end_price']), function($query) use ($startPriceDollar, $endPriceDollar) {
    return $query->where('organizations.avg_price', '>=', $startPriceDollar)->where('organizations.avg_price', '<=', $endPriceDollar);
    })->get();


$organizations= $organizationsETB->merge($organizationsUSD)->paginate(21);  

Please sign in or create an account to participate in this conversation.