1
votes

I have two query result set for $users and $logged_action and merged both.If I use all() displayed all value.I want to paginate.If I include paginate(10) instead of all.I caught a error

BadMethodCallException in Macroable.php line 74: Method paginate does not exist.

$users = DB::table('request')->select('asset_request.*')->get();
 $logged_action= DB::table('status_tracker')->select('status_tracker.*')->get();
 $users = $users->merge($logged_action); 
 $users=$users->all(); 
 return view('layouts.approval_view',['users'=>$users]);
1

1 Answers

0
votes

Maybe you can join the 2 tables by the same key that merge works and then paginate the result?

Something like that:

 $users = DB::table('request')->
join('status_tracker','on' .... )->select ('asset_request.*', ....)->paginate (10);

also did not tested but you can try this:

$users = DB::table('request')->select('asset_request.*')->paginate(10);
 $logged_action= DB::table('status_tracker')->select('status_tracker.*')->paginate(10);
 $users = $users->merge($logged_action);
 $users=$users->all();
 return view('layouts.approval_view',['users'=>$users]);

Hope it helps.