Level 50
That is because you do not tell how many results per page you want:
$users = DB::table('users')->paginate(15);
hello .
i want to get posts from category id ( 1 , 2 , 3 ) and pagination for posts relation .
table Stractur :
Posts id | title | text
category_post relationship category_id | post_id
Category id | name
my Code is : Category::whereIn('id', [1 , 2 , 3])->with('posts')->paginate()
but Pagination Dont work only posts . if posts not exist from relation but pagination is exists !
pagination will apply to the Category model
you need to turn it around and query posts having category of 1, 2 or 3 (whereHas)
https://laravel.com/docs/master/eloquent-relationships#querying-relationship-existence
Please or to participate in this conversation.