[Vuejs]-Problem with fetching data with laravel when i use relations and paginate()

0👍

SUGGESTIONS

for pagination i will suggest you use jquery datatable for proper pagination. Its quite okay and saves lots of time. see below the sample implementation:

//this section call the document ready event making sure that datatable is loaded
<script>

 $(document).ready(function() {
    $('#').DataTable();
  } );

//this section display the datatable
  $(document).ready(function() {
      $('#mytable').DataTable( {
          dom: 'Bfrtip',
          "pageLength": 10, //here you can set the page row number limit
          buttons: [
              {
                  extend: 'print',
                  customize: function ( win ) {
                      $(win.document.body)
                          .css( 'font-size', '10pt' )
                          .prepend(
                              ''
                          );

                      $(win.document.body).find( 'table' )
                          .addClass( 'compact' )
                          .css( 'font-size', 'inherit' );
                  }
              }
          ]
      } );
  } );
</script>

//you can display record on the datatable after querying from your cntroller as shown below
<div class="table-responsive col-md-12">
 <table id="mytable" class="table table-bordered table-striped table-highlight">
                                            <thead>
                                              <tr bgcolor="#c7c7c7">
                                                <th>S/N</th>
                                                 <th>Name</th>
                                              </tr>
                                            </thead>

                                            <tbody>

                                              @php
                                              $i=1;
                                              @endphp
                                                @foreach($queryrecord as $list)

                                                   <tr>
                                                   <td>{{ $i++ }}</td>
                                                   <td>{{ $list->name }}</td>
                                                   </tr>
                                               @endforeach
                                                </tbody>

                                          </table>
                                           <hr />
                                        </div>

Leave a comment