brayniverse/laravel-route-macros
Composer 安装命令:
composer require brayniverse/laravel-route-macros
包简介
A collection of useful route macros.
README 文档
README
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
统计信息
- 总下载量: 150
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-06