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
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Tighten logo

Tighten

We help companies turn great ideas into amazing apps, products, and services.

Tighten
Securing Laravel logo

Securing Laravel

The essential security resource for Laravel devs, covering everything you need to keep your apps secure. Sign up to receive weekly security tips and monthly in depth articles, diving deep into security concepts you need to know!

Securing Laravel
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises