使用此代码我可以从表中获取所有记录。但我想合并这些对象并从中创建分页,例如:
$total_legal_users = AccountLeaglUsers::all();
$total_real_users = AccountRealUsers::all();
创建分页,例如:
$total = $total_legal_users + $total_real_users;
$total->paginate(50);
怎么做?
我的测试:
$results = $total_legal_users->union($total_real_users)->paginate(50);
但我收到union
答案 0 :(得分:0)
您可以手动创建分页器。
$total_legal_users = AccountLeaglUsers::all()->toArray();
$total_real_users = AccountRealUsers::all()->toArray();
$total = array_merge($total_legal_users, $total_real_users);
$perPage = 15;
$paginator = new Illuminate\Pagination\Paginator($total, perPage);
更多地了解here