0
的功能simplePaginate()
直接調用where()
功能類似,經過工作:Laravel 5 - SimplePaginate函數在這裏不起作用?
$posts = $userA->Posts()->simplePaginate(10)->get();
的帖子()函數在用戶雄辯:
public function Posts(){
return Post::where('user_id','$this->id')->where('category','programming');
}
對於尚未一切工作正常,但問題是當我有一個以上的用戶,所以我做了這個:
//Creating Empty Collection (Working Without any problem)
$posts = new \Illuminate\Database\Eloquent\Collection;
//Getting and Adding the userA Posts (Working Without any problem)
$userA_Posts = $userA->Posts();
$posts = $posts->merge($userA_Posts);
//Getting and Adding the userB Posts (Working Without any problem)
$userB_Posts = $userB->Posts();
$posts = $posts->merge($userB_Posts);
//Getting and Adding the userC Posts (Working Without any problem)
$userC_Posts = $userC->Posts();
$posts = $posts->merge($userC_Posts);
//Here Laravel Shows me an ERROR {Method simplePaginate does not exist}
$posts = $posts->sortByDesc('created_at')->simplePaginate(10)->values()->all();
//I changed it to this, ERROR {Method simplePaginate does not exist}
$posts = $posts->sortByDesc('created_at')->values()->simplePaginate(10)->all();
//I changed it to this, ERROR {Method simplePaginate does not exist}
$posts = $posts->sortByDesc('created_at')->values()->all()->simplePaginate(10);
在laravel Documentation我沒有找到
simplePaginate()
功能,但它的工作where()
功能後,所以,請 幫助