【发布时间】:2020-05-23 00:08:12
【问题描述】:
我可以使用此方法,但不知道如何将 $user 帖子添加到此查询中:
public function getFeed()
{
$user = $this;
return Post::join('follows', function ($join) use ($user) {
$join->on('posts.timeline_type', '=', 'follows.followable_type')
->on('posts.timeline_id', '=', 'follows.followable_id')
->where('follows.user_id', '=', $user->id);
})->select('posts.*')->latest()->paginate();
}
$user 是授权用户
【问题讨论】:
标签: mysql laravel join eloquent