Package Data | |
---|---|
Maintainer Username: | vluzrmos |
Maintainer Contact: | vluzrmos@gmail.com (Vagner do Carmo) |
Package Create Date: | 2017-06-30 |
Package Last Update: | 2018-02-07 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-12-23 03:02:13 |
Package Statistics | |
---|---|
Total Downloads: | 10 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Redirect responses direct from your routes file.
composer require vluzrmos/laravel-route-redirector
Put the package Middlware in your Http Kernel file (usually in app/Http/Kernel.php
):
protected $routeMiddleware = [
\\...
'redirect' => \Vluzrmos\RouteRedirector\RouteRedirectorMiddleware::class
];
// redirect the user from /home to a route named "dashboard" (short syntax)
Route::get('/home', ['middleware' => 'redirect:route,dashboard']);
//or
Route::get('/home', ['middleware' => 'redirect', 'redirect_route' => 'dashboard']);
// Redirect User to a local path
Route::get('/home', ['middleware' => 'redirect', 'redirect_to' => '/profile']);
// Redirect User away (without prefixing with app domain)
Route::get('/home', ['middleware' => 'redirect', 'redirect_away' => '/profile']);
//using fully route parameters
Route::get('/home', ['middleware' => 'redirect', 'redirect_route' => [$name = 'dashboard', $parameters = ['something' => 'else'], $statusCode = 302, $headers ...]]);
Route::get('/home', ['middleware' => 'redirect', 'redirect_to' => [$path = '/profile', $statusCode = 302, $headers ...]]);
Route::get('/home', ['middleware' => 'redirect', 'redirect_away' => [$path = '/profile', $statusCode = 302, $headers ...]]);
Route::get('/home', ['middleware' => 'redirect', 'redirect_action' => [$action = 'Controller@method', $parameters = ['something' => 'else'], $statusCode = 302, $headers ...]]);
// all methods can be used with short syntax:
Route::get('/home', ['middleware' => 'redirect:route,dashboard']);
Route::get('/home', ['middleware' => 'redirect:to,dashboard']);
Route::get('/home', ['middleware' => 'redirect:away,path']);
Route::get('/home', ['middleware' => 'redirect:action,FQDN\Controller@method']);