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条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料