【发布时间】:2017-05-03 04:33:19
【问题描述】:
为什么 paginate 方法在这个例子中不起作用?
$shopIds = Follower::whereUserId($user->id)->orderBy('created_at','desc')->get()->pluck('shop_id')->toArray();
$shops = Shop::whereIn('id',$shopIds)->with('deals')->with('deals.likes')->paginate($this->perPage)->sortBy(function($likes) {
return $likes->count();
});
dd($shops);
感谢您的帮助;)
【问题讨论】:
-
这里的错误是什么?
-
没有错误,但是如果我使用 paginate() 方法或 get() 方法,结果是一样的。结果没有分页,所以我不明白为什么。
标签: php mysql laravel collections eloquent