1

Here is my code:

$user = TW_Accounts::where('screen_name', '=', $user)->orderBy('id', 'desc')->first();
$fllowers = $user->followings()->paginate(20);

And $followers contains 100 items. So $followers->render() contains 5 pages. All fine.


Ok, here is my new code: (I've used distinct())

$fllowers = $user->followings()->distinct()->paginate(20);

Now $followers contains 18 items. But still $followers->render() contains 5 pages. Why?! I need to make them compatible. How can I do that?

Martin AJ
  • 6,261
  • 8
  • 53
  • 111
  • 3
    Possible duplicate of [distinct() with pagination() in laravel 5.2 not working](https://stackoverflow.com/questions/41283083/distinct-with-pagination-in-laravel-5-2-not-working) – Difster Jul 31 '17 at 04:41
  • what does using pagination before distinct gives ?? – Exprator Jul 31 '17 at 04:43
  • @Exprator It doesn't work kinda.. I've executed that for 1 minute and it's still working. Seems like a heavy query. – Martin AJ Jul 31 '17 at 04:47
  • The use of distinct and pagination is a known bug in Laravel. I'd suggest rewriting your query. If you provide a complete example of the data and desired result, I'm sure you'll get some help. – fubar Jul 31 '17 at 05:32

0 Answers0