首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >删除Laravel路由中的HTTP方法

删除Laravel路由中的HTTP方法
EN

Stack Overflow用户
提问于 2015-08-29 13:02:52
回答 1查看 1.1K关注 0票数 0

我正在使用Laravel资源路由(通过控制器)。这是路由代码

代码语言:javascript
复制
Route::resource( 'difficulty', 'DifficultyController', [ 'only' => [ 'index', 'show', 'update', 'create' ] ] );

以下是创建的路线

代码语言:javascript
复制
+--------+----------+-------------------------+-------------------+--------------------------------------------------+------------+
| Domain | Method   | URI                     | Name              | Action                                           | Middleware |
+--------+----------+-------------------------+-------------------+--------------------------------------------------+------------+
|        | GET|HEAD | difficulty              | difficulty.index  | App\Http\Controllers\DifficultyController@index  |            |
|        | GET|HEAD | difficulty/create       | difficulty.create | App\Http\Controllers\DifficultyController@create |            |
|        | PATCH    | difficulty/{difficulty} |                   | App\Http\Controllers\DifficultyController@update |            |
|        | GET|HEAD | difficulty/{difficulty} | difficulty.show   | App\Http\Controllers\DifficultyController@show   |            |
|        | PUT      | difficulty/{difficulty} | difficulty.update | App\Http\Controllers\DifficultyController@update |            |
+--------+----------+-------------------------+-------------------+--------------------------------------------------+------------+

它很好,但我不需要“头”和“补丁”方法,我想删除它们。因此,列表路径将显示以下内容

代码语言:javascript
复制
+--------+----------+-------------------------+-------------------+--------------------------------------------------+------------+
| Domain | Method   | URI                     | Name              | Action                                           | Middleware |
+--------+----------+-------------------------+-------------------+--------------------------------------------------+------------+
|        | GET      | difficulty              | difficulty.index  | App\Http\Controllers\DifficultyController@index  |            |
|        | GET      | difficulty/create       | difficulty.create | App\Http\Controllers\DifficultyController@create |            |
|        | GET      | difficulty/{difficulty} | difficulty.show   | App\Http\Controllers\DifficultyController@show   |            |
|        | PUT      | difficulty/{difficulty} | difficulty.update | App\Http\Controllers\DifficultyController@update |            |
+--------+----------+-------------------------+-------------------+--------------------------------------------------+------------+

有可能做到吗?我用的是Laravel5.1

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-30 02:31:18

只做显式声明怎么样?

代码语言:javascript
复制
Route::get('/difficulty','DifficultyController@index');
Route::get('/difficulty/create','DifficultyController@create');
Route::get('/difficulty/{difficulty}','DifficultyController@show');
Route::put('/difficulty/{difficulty}','DifficultyController@update');

我甚至更喜欢这样做,因为它可以更清楚地了解应用程序的功能。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32286349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档