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