6
0
Fork 0

修改文章列表接口

release
vine_liutk 2021-12-17 21:21:05 +08:00
parent 334e6013aa
commit 699be72a75
3 changed files with 6 additions and 1 deletions

View File

@ -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);

View File

@ -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']);
});
}

View File

@ -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']);
});
}