I’m sorry, I have a problem with my laravel pagination Gives me one by one page for example, in my table 16 row I make paginate (10), the pagination gives me in the first page from 1 to 10 and in the second page from 1 to 6 I want the normal pagination from 1 to 10 and from 11 to 16 any help, please
public function allappointmnts(){ $allapo=DB::table('bookappoitments')->orderBy('times.id') ->join('users','bookappoitments.users_id','users.id') ->join('times','bookappoitments.times_id','times.id') ->join('dates','bookappoitments.Dates_id','dates.id') ->paginate(10); return view('admin.Managers.allappoinments',compact('allapo')); }
in the blade page:
<div class="text-center"> {!! $allapo->links(); !!} </div>
The table :
<table class="table table-bordered table-hover table-striped"> <thead> <tr> <th>#</th> <th>Date</th> <th>Time</th> <th>Employee</th> <th>Name</th> <th>Email</th> <th>Company</th> <th>Phone</th> <th>Location</th> <th>Remarks</th> <th style="text-align: center;">Action</th> </tr> </thead> <tbody> <tr> @foreach($allapo as $Appointments) <td>{{ $loop->index+1 }}</td> <td>{{ $Appointments->Dates }}</td> <td>{{ $Appointments->from_to }}</td> <td>{{ $Appointments->name }}</td> <td>{{ $Appointments->gustname }}</td> <td>{{ $Appointments->gustemail }}</td> <td>{{ $Appointments->gustcompany }}</td> <td>{{ $Appointments->gustphone }}</td> <td>{{ $Appointments->Location }}</td> <td>{{ $Appointments->Remarks }}</td> <td> <a class="btn btn-success btn-mini deleteRecord " href="{{url('showbymanagment',$Appointments->id)}}">Show</a> </td> </tr> @endforeach
Advertisement
Answer
to see the correct number change the line
<td>{{ $loop->index+1 }}</td>
to:
<td>{{ ($allapo->currentPage() - 1) * $allapo->perPage() + $loop->iteration }} <td>