Preventing duplicate SQL calls in Laravel functions using the once helper
Sometimes, you may want to prevent multiple SQL calls when the same Laravel function is used in multiple places. https://laravel-news.com/once-helper https://la
GGAMI
Sometimes, you may want to prevent multiple SQL calls when the same Laravel function is used in multiple places.
https://laravel-news.com/once-helper https://laravel.com/docs/11.x/helpers#method-once
The helper you can use for this is the once helper function. It's better than I expected.
{
return once(function () use ($exchange) {
return self::where('exchange', $exchange)
->get()
->pluck('name')
->toArray();
});
}