cache bug fix
This commit is contained in:
		| @@ -17,7 +17,8 @@ final class RecentArticles extends Controller | ||||
|      */ | ||||
|     public function __invoke() | ||||
|     { | ||||
|         return Cache::remember('articles.recent', 300, function () { | ||||
|         $currentPage = request()->get('page',1); | ||||
|         return Cache::remember('articles.recent_'.$currentPage, 300, function () { | ||||
|             return [ | ||||
|                 "articles" => Article::with('source', 'topics') | ||||
|                     ->latest("published_date") | ||||
|   | ||||
| @@ -31,7 +31,8 @@ class SourcesAPIController extends Controller | ||||
|      */ | ||||
|     public function show(Source $source) | ||||
|     { | ||||
|         return Cache::remember($source->slug. '32', 300, function () use ($source) { | ||||
|         $currentPage = request()->get('page',1); | ||||
|         return Cache::remember($source->slug. '_'. $currentPage, 300, function () use ($source) { | ||||
|             return response()->json([ | ||||
|                 'source' => new SourceResource($source), | ||||
|                 'articles' =>  $source->articles()->with('source')->latest('published_date')->paginate(8) | ||||
|   | ||||
| @@ -30,7 +30,8 @@ class TopicsAPIController extends Controller | ||||
|      */ | ||||
|     public function show(Topic $topic) | ||||
|     { | ||||
|         return Cache::remember('topic_'.$topic->slug, 300, function () use ($topic) { | ||||
|         $currentPage = request()->get('page',1); | ||||
|         return Cache::remember($topic->slug. '_'.$currentPage, 300, function () use ($topic) { | ||||
|             return response()->json([ | ||||
|                 'topic' => new TopicResource($topic), | ||||
|                 'articles' => $topic->articles()->with('source')->latest('published_date')->paginate(8) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user