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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?