简体   繁体   中英

Multiple pagination

how to get pagination in this code had done but fail:

Job::with['institute','user']->find(1)->paginate(10)

$job = Job::with(['institute','users'])->find($job_id);

how to get pagination for users only

If you want to get a single job object and paginate over the linked users, you can load the job first and then get the paginated users object manually via the relation.

$job = Job::with(['institute'])->find($job_id);
$users = $job->users()->paginate(10);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM