brayniverse/laravel-route-macros
| Install | |
|---|---|
composer require brayniverse/laravel-route-macros |
|
| Latest Version: | v1.0.0 |
| PHP: | ^5.5.9 || ^7.0 |
| License: | MIT |
| Last Updated: | Jun 27, 2017 |
| Links: | GitHub · Packagist |
Laravel route macros
Installation
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.
Brayniverse\RouteMacros\ServiceProvider::class
Usage
view
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');
redirect
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);
Credits
Related Packages
Simple PHP router that works with query-string and uri-segments, laravel filter...
Simple, fast PHP router that is easy to get integrated and in almost any project...
Enhanced Router is an extension to the Laravel 4 router and provides some enhanc...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.0.0 | ^5.5.9 | | 5.1.* | | MIT |