laravel在这种情况下我应该使用哪个路由或链接 [英] laravel which route or link should I use for this case

查看:101
本文介绍了laravel在这种情况下我应该使用哪个路由或链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个xmldocument模型,可以通过这种方式显示其配置文件:

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:

添加一般信息是资源general_information

添加主信息是资源master_information

添加一般信息是资源general_information

但是他们每个人都必须知道xmldocument ID.就我而言,每个人都应该知道他们属于xmldocument = 4

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` ?

或此链接

`public/generalinformation/create` ?

在第二种情况下,我必须传递xmldocument id,但是我真的可以使用a标记来做到这一点吗?

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

推荐答案

,它与您的业务逻辑有关,因此没有最佳方法或最佳方法.比这更好的是,一切都还给你..

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 ..

现在有关使用

public/generalinformation/create

通常,您应该将文档的id附加到链接,以便可以在下一页中处理它,因为a标记仅提供_GET值,但是在Laravel中,您可以使用slug例如解决此问题,以便您的链接可以是

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

这样,您可以在数据库中查询slug并获取xml文档的id.

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.

这篇关于laravel在这种情况下我应该使用哪个路由或链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆