mardi 8 septembre 2020

Laravel - Paginate child records passing parent record ID

I have a parent model called Integration and a child model called IntegrationError. In a balde view a list all the Integration records and at the end of each, I count child IntegrationError records.

When I click on total count child records, I go to another view for listing child records (I pass the integration ID)

<td><a href="">

In IntegrationError controller I search for all the records for the parent ID that I sent:

public function index(Request $request)
    {
        $integrationserrors = IntegrationError::where('integration_id', $request->id)->orderBy('created_at', 'desc')->simplePaginate(15);
        return view('pages.admin.integrations.errors', compact('integrationserrors'));
    }

The first set of 15 records are correctly shown in view and the URL formed is (205 is the parenet id): http://127.0.0.1:8000/administration/integrations/errors?id=205

But when I click next button, context is lost and the URL formed becomes: http://127.0.0.1:8000/administration/integrations/errors?page=2

I don't know if the query done in controller is the problem or how can I maintain context in order to see next set of records while clicking Next button.

Anyone can help me?

Regards!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire