brayniverse / laravel-route-macros by brayniverse

A collection of useful route macros.
Package Data
Maintainer Username: brayniverse
Maintainer Contact: (Christopher L Bray)
Package Create Date: 2017-03-06
Package Last Update: 2017-06-27
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2020-08-02 15:01:51
Package Statistics
Total Downloads: 149
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 20
Total Watchers: 2
Total Forks: 4
Total Open Issues: 2

Laravel route macros

Build Status Total Downloads Latest Stable Version Latest Unstable Version License


Begin by installing the package through Composer.

$ composer require brayniverse/laravel-route-macros

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




Normally you'd have to return a view in either a controller method or callback like the following:

public function contact()
  return view('contact');

// or

Route::get('/contact', function () {
  return view('contact');

Now you can do the same in one line.

Route::view('/contact', 'contact');


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');

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);