duanhao1004 2017-03-28 20:01
浏览 181
已采纳

使用资源路由时命名Laravel视图路由

Problem

I have been struggling all day to find a good convention to name view routes in Laravel (5.4).
Let's say that I am using resource routes. But I also need to declare a lot of view routes, what is a safe and best practice for declaring such routes?

Example:

I have the following resource routes:

GET /tickets/12/messages
GET /tickets/12/messages/5
POST /tickets/12/messages
PUT /tickets/12/messages/5
PATCH /tickets/12/messages/5
DELETE /tickets/12/messages/5

I also need to define routes for:

  • Displaying the view to edit a particular message.
  • Displaying the view to add a particular message to a ticket.
  • Displaying the view to create a particular ticket.
  • Displaying the view to show all the tickets in the system.
  • Displaying the view to show all the tickets that belong to a particular user.

And many others... The question is: How would you define the routes I described?
Many thanks!

  • 写回答

2条回答 默认 最新

  • duanji8615 2017-03-28 20:04
    关注

    The Laravel way to build routes for CRUD is to use the Route::resource() method:

    Route::resource('tickets', 'TicketController');
    

    You can see a list of generated routes with php artisan route:list command.

    https://laravel.com/docs/5.4/controllers#resource-controllers

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭