【问题标题】:laravel what is different between post and other in web.phplaravel web.php 中的 post 和 other 有什么不同
【发布时间】:2020-07-31 19:27:20
【问题描述】:

我试图在 laravel 中清楚地理解 web.php 中 4 行(Post、Get 和 Match 以及 Any)行之间的区别,

像这样。

使用帖子:

Route::post('/admin/add_coupon','CouponsController@addCoupone');

使用匹配:

Route::match(['get','post'], '/admin/add_coupon','CouponsController@addCoupone');

使用任何:

Route::any('/admin/add_coupon','CouponsController@addCoupone');

我的问题是运行相同时以上三个有什么不同!哪一个是最好的代码可以用于电子商务网站的最新版本!以及为什么我们有三种不同的方式来编写代码!他们是为了速度,还是为了节省代码或代码质量!我很难决定用哪种方式为繁重的网站编写代码!任何建议! 非常感谢。

【问题讨论】:

  • 区别在于它处​​理的HTTP方法。

标签: laravel post get


【解决方案1】:

了解 HTTP 动词或 REST API 动词 (https://restfulapi.net/http-methods/)。

  • 发布:仅POST 方法
  • 匹配GET y POST 方法(在您的示例中)
  • 任何GETPOSTPUT

我建议你使用路由和控制器类型“资源”(https://laravel.com/docs/7.x/controllers#resource-controllers

【讨论】:

    猜你喜欢
    • 2019-05-16
    • 2021-08-24
    • 1970-01-01
    • 2021-12-03
    • 1970-01-01
    • 1970-01-01
    • 2020-11-15
    • 2019-03-13
    • 2021-02-11
    相关资源
    最近更新 更多