Why this is not working?
$myFriends =Friend::where('status',1)->pluck('user_id');
$users = User::Where('active',1)->WhereNotIn('id',$myFriends)->get();
$users =$users->skip(2)->take(3);
it gives following error
BadMethodCallException in Macroable.php line 74: Method Skip does not exist.
Use slice
method instead of skip
.
$users->slice(2)->take(3);
Or in a shorthand:
$users->slice(2, 3);
It skips 2 first records and returns next 3 records.
With respect to @ikurcubic's comment The answer updated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With