PHPackages                             jcergolj/after-action-redirect-pagination-url-for-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jcergolj/after-action-redirect-pagination-url-for-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jcergolj/after-action-redirect-pagination-url-for-laravel
=========================================================

After CREATE, UPDATE or DELETE action paginated redirect url for laravel

v2.6(1y ago)67.5kMITPHP

Since May 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jcergolj/after-action-redirect-pagination-url-for-laravel)[ Packagist](https://packagist.org/packages/jcergolj/after-action-redirect-pagination-url-for-laravel)[ RSS](/packages/jcergolj-after-action-redirect-pagination-url-for-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (9)Used By (0)

### Why

[](#why)

[![Watch the video](https://camo.githubusercontent.com/0620fdc2f315c403423cbfdc0a619c5ad07be303d7ab20bca9f8a8ae00e4f62a/68747470733a2f2f696d672e796f75747562652e636f6d2f76692f64456a414b5544677433552f687164656661756c742e6a7067)](https://www.youtube.com/embed/dEjAKUDgt3U)

The After Action Redirect Pagination URL for Laravel package provides a solution for two issues that developers may encounter when working with pagination in their Laravel application. These issues include [losing query parameters and the current page when editing an item and being redirected to the first page of the index](#saving-and-redirecting-to-last-index-url-with-query-parameters), as well as being [redirected to an empty last page after deleting the last item on the last page](#redirect-to-last-page-with-items-after-deleting-last-item-on-last-page).

### Installation

[](#installation)

```
composer require jcergolj/after-action-redirect-pagination-url-for-laravel
```

### Saving and Redirecting to Last Index URL with Query Parameters

[](#saving-and-redirecting-to-last-index-url-with-query-parameters)

This package allows you to save the full URL, including any query parameters, of the index page in the intended URL session. After a create or update action, you can use the `to_intended_route` helper method to be redirected to the same page. You can also include or exclude routes from the intended URL saving mechanism for greater customization.

To use this feature, add the following code to your controller:

```
    return to_intended_route('users.index');
```

By default, `to_intended_route` will redirect to the last intended URL. If no URL was intended, it will redirect to the users.index route.

Example:

```
