Eager-load categories on related articles in API response
The related articles query was missing ->with(['categories']), causing the frontend ArticleCard to crash on undefined categories. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -60,7 +60,8 @@ class ArticleController extends Controller
|
|||||||
$article->incrementViewCount();
|
$article->incrementViewCount();
|
||||||
|
|
||||||
// Get related articles (same content_type, excluding current)
|
// Get related articles (same content_type, excluding current)
|
||||||
$related = Article::active()
|
$related = Article::with(['categories'])
|
||||||
|
->active()
|
||||||
->forAccessLevel()
|
->forAccessLevel()
|
||||||
->where('content_type', $article->content_type)
|
->where('content_type', $article->content_type)
|
||||||
->where('id', '!=', $article->id)
|
->where('id', '!=', $article->id)
|
||||||
|
|||||||
Reference in New Issue
Block a user