MrMooky's avatar

Middleware $request->merge with Livewire pagination

I have a Middleware where I need to check the current "base" and whether or not the current user has access to it. If the user has access, I merge it with the current request so I can access it in my controllers. The part in my Middleware looks like this:

$request->merge([
   'base' => $base,
]);

return $next($request);

That works perfectly fine. But if there is a Livewire pagination on that page, all base parameters are appended as query string in the url directly on page load, e.g.

https://example.test/dashboard/?base[id]=7&base[uuid]=811f507e-5746-431c-b8e9-c6efde2260b1&base[title]=Optio+eligendi+porro+placeat+est+possimus+sit.&base[owner_id]=7&base[identifier]=omnis-aperiam&base[slug]=omnis-aperiam&base[language]=en&base[public]=1&base[allow_bots]=1 ... etc

I tried to prevent this by setting the following within my Livewire component, but doesn't work:

protected $queryString = [
    'page' => ['except' => 1],
];

So, how can I prevent this but still be able to use pagination with Livewire?

0 likes
2 replies

Please or to participate in this conversation.