Category index page n+1 other category issue solved..

This commit is contained in:
Cüneyt Şentürk 2023-07-21 11:40:08 +03:00
parent 18fa397df1
commit abfa4cffac

View File

@ -3,6 +3,7 @@
namespace App\Traits; namespace App\Traits;
use App\Models\Setting\Category; use App\Models\Setting\Category;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str; use Illuminate\Support\Str;
trait Categories trait Categories
@ -34,7 +35,10 @@ trait Categories
public function getTransferCategoryId(): mixed public function getTransferCategoryId(): mixed
{ {
return Category::other()->pluck('id')->first(); // 1 hour set cache for same query
return Cache::remember('transferCategoryId', 60, function () {
return Category::other()->pluck('id')->first();
});
} }
public function isTransferCategory(): bool public function isTransferCategory(): bool