Waavi / save-url by sildraug

Laravel 5 package to redirect users to the last visited page on login.
611
9
2
Package Data
Maintainer Username: sildraug
Maintainer Contact: info@waavi.com (Waavi)
Package Create Date: 2015-12-31
Package Last Update: 2017-08-10
Language: PHP
License: MIT
Last Refreshed: 2024-04-25 15:02:49
Package Statistics
Total Downloads: 611
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 9
Total Watchers: 2
Total Forks: 4
Total Open Issues: 1

Laravel 5 package to redirect to last visited url on login

Latest Version on Packagist Software License Build Status Total Downloads

Introduction

This package allows you to easily redirect users to the last visited page on login.

WAAVI is a web development studio based in Madrid, Spain. You can learn more about us at waavi.com

Laravel compatibility

Laravel | translation :---------|:---------- 5.1.x | 1.0.x 5.2.x | 1.0.1 and up 5.3.x | 1.0.2 and up

Installation

Require through composer

composer require waavi/save-url 1.0.x

Or manually edit your composer.json file:

"require": {
	"waavi/save-url": "1.0.x"
}

In config/app.php, add the following entry to the end of the providers array:

Waavi\SaveUrl\SaveUrlServiceProvider::class,

Publish the configuration file:

php artisan vendor:publish --provider="Waavi\SaveUrl\SaveUrlServiceProvider"

Usage

Cached urls

By default, the last visited URL visited by a user is saved in Session. URLs must follow these criteria to be saved:

- Only GET requests are saved.
- AJAX requests are not saved.
- If the user is logged in, no urls are saved.

Excluding urls from the cache

If you want to exclude certain urls from the url cache, like for example the login and signup pages, you may use the provided "doNotSave" middleware:

// app/Http/routes.php

Route::get('/login', ['middleware' => 'doNotSave', 'uses' => 'AuthController@login']);

Redirecting after login

To redirect the user to the last saved url, such as after authentication, you may use:

public function login() {
	/** Auth user **/
	if ($success) {
		redirect()->toSavedUrl();
	}
}