I am unable to display mysql rows over 10,000 from mysql within Laravel.
I have read about using chunk but i am unable to get this working, i thought i could be done using the datatable javascript, this is displaying a maximum 10 records per page which is what i want, however it tries to load the whole 10,000 records first before placing them in sets of 10. i have placed my code below.
Thanks in advance
My controller for the page is like this:
    public function index($bzname)
{
    $user = Auth::guard('business')->user();
    $business_admin= BusinessAdmin::where('user_id', $user->id)->first();
    $business = Business::where('business_name', $bzname)->first();
    $users = User::join('business_users', 'users.id', '=', 'business_users.user_id')
        ->leftJoin('user_login_times', 'users.id', '=', 'user_login_times.user_id')
        ->leftJoin('social_logins', 'users.id', '=', 'social_logins.user_id')
        ->where('business_users.business_id', $business_admin->business_id)
        ->select('users.*', 'social_logins.provider', 'social_logins.social_id', 'user_login_times.login_time')
        ->orderBy('login_time', 'desc')->get();
    $users = $users->unique('id');
    // Get User Roles
    $roles = Role::all();
    $current_year = date('Y');
    $data = [
        'user' => $user,
        'users' => $users,
        'roles' => $roles,
        'bzname' => $bzname,
        'current_year' => $current_year,
        'bzadmin' => $business->owner_name,
    ];
    return View('pages.business_admin.users.show-users', $data);
}
With my user page displaying as:
  <tbody id="users_table">
    @foreach($users as $user)
     <tr>
      <td>{{$loop->index + 1}}</td>
       <td><img src="@if($user->image_url) {{ $user->image_url }} @else /images/faces/empty.png @endif" class="mr-2" alt="image"></td>
        <td class="hidden-xs">{{$user->first_name}}</td>
        <td class="hidden-xs">{{$user->last_name}}</td>
        <td class="hidden-xs" width="100px"><a href="mailto:{{ $user->email }}"          title="email {{ $user->email }}">{{ $user->email }}</a>
         </td>
         <td style="text-transform: capitalize;">{{ $user->gender }}</td>
          <td>{{ $current_year - $user->year }}</td>
          <td style="text-transform: capitalize;">{{ $user->country }}</td>
          <td>
          @if($user->provider == null)
          Email
          @else
         {{ $user->provider }}
         @endif
         </td>
         <td>{{ $user->login_time }}</td>
         <td class="actions" width="180px">
         <a class="btn btn-sm btn-success" href="{{ URL::to('/business/'.$bzname.'/admin/users/' . $user->id) }}"
                                           data-toggle="tooltip" title="View">
                                          {!! trans(('usersmanagement.buttons.show'))!!}
                                        </a>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
<script type="text/javascript">
    $(function() {
        $('#user-listing').dataTable({
            dom: 'Bfrtip',
            buttons: [
                'copyHtml5', 'excelHtml5', 'pdfHtml5', 'csvHtml5'
            ],
            "iDisplayLength": 10,
        });
        $('#user-listing_filter').attr('style', 'display: none');
    });
</script>
 
     
     
     
    