optimize laravel eloquent built-in functions
Clash Royale CLAN TAG#URR8PPP
optimize laravel eloquent built-in functions
I am optimizing a existing laravel project which has following code segment. this method is calling from another foreach. but this method gets almost 3 seconds to process a single round.is there anything that i can do to optimize following code.
public function getFavouriteForRace($raceId)
$race = $this->raceRepository->find($raceId);
$selections = $this->selectionRepository->getSelectionsForRace($raceId);
//set product
$products = new EloquentResourceCollection($race->products, 'ResourcesProductResource');
$selections = $selections->map(function ($v) use ($products)
$v->setProducts($products);
return $v;
);
$selections = $selections
->filter(function ($v)
return $v->selectionStatus == SelectionStatusRepositoryInterface::SELECTION_STATUS;
)
->sortBy(function ($v) use ($race)
return $v->getBetTypePrice(BetTypeRepositoryInterface::TYPE_WIN, (bool)$race->fixed_odds_enabled) ? : 999999;
);
return $selections->first();
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.