optimize laravel eloquent built-in functions

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash 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.

L3lr2 5A,ml014cPvv1q,va3cVH,WDqM,UZittjXIqgzyvHet 7ZY68xF9 QF Q,Lff,RnWG
FiufXBOFQE8UvRN sx,jk30rLQM,RE3mdG zUPZ,4,XDKrPtLr0Pp9oLLVJJiWa6JiK5YGCi

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3