brayniverse / laravel-redirect-helper by brayniverse

Syntactic sugar for those occasions when you want to redirect from an old route to a new route.
271
6
1
Package Data
Maintainer Username: brayniverse
Maintainer Contact: chris@brayniverse.com (Christopher L Bray)
Package Create Date: 2016-08-29
Package Last Update: 2017-01-13
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2020-01-15 15:18:40
Package Statistics
Total Downloads: 271
Monthly Downloads: 6
Daily Downloads: 0
Total Stars: 6
Total Watchers: 1
Total Forks: 1
Total Open Issues: 2

Laravel redirect helper

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

Syntactic sugar for those occasions when you want to redirect from an old route to a new route.

This package adds a Route::redirect() helper method so you don't have to create a closure for each redirect.

Installation

Begin by installing the package through Composer.

$ composer require brayniverse/laravel-redirect-helper

Then add the following to your providers array in config/app.php.

Brayniverse\LaravelRedirectHelper\ServiceProvider::class

Usage

Normally you'd have to create a closure to redirect to the new route.

Route::get('/contact_us', function () {
  return redirect('/contact');
});

Now you can do the same in one line.

Route::redirect('/contact_us', '/contact');

Setting status code

Optionally, you can pass a third argument to Route::redirect() which will set the status code when redirecting. If you do not specify a status code, the package will use 301 as the status code.

Route::redirect('/contact_us', '/contact', 302);

Credits