Polyscope - The agent-first dev environment for Laravel

Remember Query Strings

reinink/remember-query-strings image

Remember Query Strings stats

Downloads
257.9K
Stars
71
Open Issues
2
Forks
8

View on GitHub →

Laravel middleware that automatically remembers and restores query strings.

Remember Query Strings

Remember Query Strings is a Laravel middleware that automatically remembers and restores query strings. It does this by remembering the last query strings visited in the session. Later, when you visit that same route, if no query strings are provided, the middleware will automatically restore them from the sessions via a redirect.

Installation

You can install this package via Composer:

composer require reinink/remember-query-strings

Setup

First register the route middleware in your App\HttpKernel class:

protected $routeMiddleware = [
// ..
'remember' => \Reinink\RememberQueryStrings::class,
];

Usage

Now you can use this middleware just like any other middleware. For example, in your routes:

Route::get('users')->name('users')->uses('UsersController@index')->middleware('remember');

Or in a controller:

class UserController extends Controller
{
public function __construct()
{
$this->middleware('remember')->only('index');
}
}

Opting out

If you'd like to visit a page without remembering the query strings, pass ?remember=no to disable this behviour for that visit.

Forgetting query strings

To forget previously remembered query strings, simply pass ?remember=forget.

reinink photo

👨‍💻 Helped Adam build @tailwindcss. ⏩ Creator of @inertiajs. 😍 Fan of @laravelphp. ⚽ Dad to three great kids. ❤️ Husband to Amy. 🙏 Follower of Christ

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Reinink Remember Query Strings Related Articles

The Inertia.js v2 Beta is Here image

The Inertia.js v2 Beta is Here

Read article
Eloquent Performance Patterns video course by Jonathan Reinink (sponsor) image

Eloquent Performance Patterns video course by Jonathan Reinink (sponsor)

Read article
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
Honeybadger logo

Honeybadger

Simple developer-focused application monitoring for Laravel. Error tracking, log management, uptime monitoring, status pages, and more!

Honeybadger
Blastup logo

Blastup

Blastup provides social media enhancement services including buying Instagram likes, followers, and views, with features like instant delivery and a variety of packages to suit different needs.

Blastup
LoadForge logo

LoadForge

Scalable load testing for web apps & APIs. Simulate real-world traffic and identify breaking points and performance limits with powerful, scalable load tests designed for Laravel.

LoadForge
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit