Basically, this is the first page (you can see the first picture). There are 8 pieces of data in total, and 2 pieces of data will be displayed on each page. First picture
So when I click on the second page, the third page is lost and cannot be clicked. You can see the second image (it's the second image from the second page, but as you can see, there's no button for me to click on the third page)
As you can see below, I tried adding the data table and putting ->setOffset($start) into the code. But it doesn't work. Please anyone help me.
public function reservationListing(Request $request) { $req = $request->all(); $query = EventReservation::selectRaw("reservation_date,event_reservations.outlet_id,event_reservations.event_id,SUM(event_reservations.total_adults) as ttl_adult, SUM(event_reservations.total_kids) as ttl_kid,SUM(event_reservations.total_adults event_reservations.total_kids) as ttl_pax, SUM(CASE WHEN event_reservations.total_attendees is NULL then 0 Else event_reservations.total_attendees End) as ttl_attended, SUM(CASE WHEN payment_status = 'pending' THEN 1 ELSE 0 END) as ttl_pending,SUM(CASE WHEN payment_status = 'paid' THEN 1 ELSE 0 END) as ttl_paid, events.name as event_name,outlets.name as outlet_name") ->leftjoin("events", "events.id", "=", "event_reservations.event_id") ->leftjoin("outlets", "outlets.id", "=", "event_reservations.outlet_id") ->groupby('reservation_date') ->groupby('outlet_id') ->groupby('event_id'); if (!empty($req['date_to']) && !empty($req['date_to'])) { $query->whereRaw("DATE(reservation_date) BETWEEN '".$req['date_from']."' AND '".$req['date_to']."'"); } if (!empty($req['outlet_id'])) { $query->where("event_reservations.outlet_id", $req['outlet_id']); } if (!empty($req['event_id'])) { $query->where("event_reservations.event_id", $req['event_id']); } if (!empty($req['start'])) { $query->skip($req['start']); } if (!empty($req['start'])) { $query->take($req['length']); } $query->orderBy("reservation_date"); $reservationList = $query->get(); $start = ($request->start) ? $request->start : 0; return Datatables::of($reservationList) ->setOffset($start) ->addIndexColumn() ->make(true); }
I already got the answer, I just changed some code and deleted some code:
This is the complete code of the function: