2017 © Pedro Peláez
 

library laravel-route-macros

A collection of useful route macros.

image

brayniverse/laravel-route-macros

A collection of useful route macros.

  • Tuesday, June 27, 2017
  • by brayniverse
  • Repository
  • 3 Watchers
  • 20 Stars
  • 127 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

Laravel route macros

Build Status Total Downloads Latest Stable Version Latest Unstable Version License, (*1)

Installation

Begin by installing the package through Composer., (*2)

$ composer require brayniverse/laravel-route-macros

Then add the following to your providers array in config/app.php., (*3)

Brayniverse\RouteMacros\ServiceProvider::class

Usage

view

Normally you'd have to return a view in either a controller method or callback like the following:, (*4)

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

// or

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

Now you can do the same in one line., (*5)

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

redirect

Normally you'd have to create a closure to redirect to the new route., (*6)

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

Now you can do the same in one line., (*7)

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., (*8)

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

Credits

The Versions