fix(blog): serialize resource collections cleanly before caching in HomeController
Deploy Backend / deploy (push) Successful in 47s
Deploy Backend / deploy (push) Successful in 47s
This commit is contained in:
1 parent
accf0b6aab
commit
cb844d2ee7
1 file changed
+5
-5
@@ -29,7 +29,7 @@ class HomeController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$lang = $request->input('lang');
|
||||
$cacheKey = 'blog_homepage_' . ($lang ?: 'all');
|
||||
$cacheKey = 'blog_homepage_v2_' . ($lang ?: 'all');
|
||||
|
||||
// Bypass cache during testing so factory states remain immediate
|
||||
if (app()->environment('testing')) {
|
||||
@@ -73,10 +73,10 @@ class HomeController extends Controller
|
||||
: collect();
|
||||
|
||||
return [
|
||||
'latest_posts' => PostResource::collection($latestPosts),
|
||||
'latest_categories' => CategoryResource::collection($latestCategories),
|
||||
'most_viewed_posts' => PostResource::collection($mostViewedPosts),
|
||||
'random_posts' => PostResource::collection($randomPosts),
|
||||
'latest_posts' => PostResource::collection($latestPosts)->resolve(),
|
||||
'latest_categories' => CategoryResource::collection($latestCategories)->resolve(),
|
||||
'most_viewed_posts' => PostResource::collection($mostViewedPosts)->resolve(),
|
||||
'random_posts' => PostResource::collection($randomPosts)->resolve(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user