I try to cache all request records for 60 minutes with the following method (method 1)
Route::get('categoryList', function() { return app\CategoryDetails::remember(60)->get(); });
I followed this tutorial link (Tip 5: Cache Database Requests)
But I get this error:
Call the undefined method Illuminate\Database\Query\Builder::remember()
I donβt know what I am missing here.
By the way, I know that I can cache entire records with the following method (method 2):
Route::get('categoryList', function() { $category = Cache::remember('category', 10, function() { return \App\CategoryDetails::all(); }); return $category; });
and it works great.
I'm just wondering why the first method doesn't work for me.
source share