修改文章列表接口
parent
334e6013aa
commit
699be72a75
|
|
@ -34,7 +34,8 @@ class ArticleController extends Controller
|
|||
'health'=> config('settings.article_health'),
|
||||
], $cate);
|
||||
$query = Article::query()->with(['likesInfo'=>function ($q) use ($request) {
|
||||
return $q->where('user_id', $request->user()->id);
|
||||
$user_id = $request->user()?->id;
|
||||
return $q->where('user_id', $user_id??0);
|
||||
}])->where('is_show', 1);
|
||||
if ($categoryId) {
|
||||
$query->where('category_id', $categoryId);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ class CreateArticleLikesLogsTable extends Migration
|
|||
$table->unsignedBigInteger('article_id')->column('文章');
|
||||
$table->unsignedBigInteger('user_id')->column('用户');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['article_id', 'user_id']);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ class CreateArticlePointsLogsTable extends Migration
|
|||
$table->unsignedBigInteger('article_id')->column('文章');
|
||||
$table->unsignedBigInteger('user_id')->column('用户');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['article_id', 'user_id']);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue