laravel which route or link should I use for this case

大兔子大兔子 提交于 2019-12-02 19:15:02

问题


I have an xmldocument model, which I can show its profile in this way:

`public/xmldocument/4`

From this page, there are three links, which are:

add general information 

add master information

add general information

each of them is for a resource. for example:

add general information is the create of the resource general_information

add master information is the create of the resource master_information

add general information is the create of the resource general_information

But each of them must know the xmldocument id. in my case, each of them should know that they are belongs to the xmldocument = 4

My question is should I route each of them to this link

`public/xmldocument/4/generalinformation/create` ?

or to this link

`public/generalinformation/create` ?

in the second case, I have to pass the xmldocument id, but can I really do that using the a tag?


回答1:


as Oni said, its something related to your business logic, so there are no way as the best way or a way which is better than this way, its all back to you ..

now about the second question sending the id of the document when using

public/generalinformation/create

in general you should append the id of the document to the link so that you can handle it in the next page as a tag will only provide _GET values, but in Laravel you can use slug for example to solve this issue so your link can be something like

public/xml_doc_slug/generalinformation/create

so this way you query your database for the slug and get the id of the xml document.

In my opinion, try to make your URL's as simple as you can so that you can deal with it later.



来源:https://stackoverflow.com/questions/24500198/laravel-which-route-or-link-should-i-use-for-this-case

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!