Laravel可选路由参数 [英] Laravel optional routing parameter

查看:95
本文介绍了Laravel可选路由参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建路线文件,对于我们正在构建的应用程序,我们可能具有以下路线:

I am trying to build up my routes file and for the application we are building we may have a route such as:

/services/{game}/{id}

是否可以使用该{game}参数,但实际上没有将其传递给控制器​​?它基本上就在那儿,但不必是任何特定的东西,控制器也不需要知道它在那儿,纯粹是为了让用户眼中的URL有意义.

Is there a way to have that {game} parameter, but not actually pass it to the controller? Its basically there, but doesn't have to be anything specific and the controller doesn't need to know its there, it's purely for the users eye to make their URL make sense.

推荐答案

这完全有可能,您可以在控制器中捕获它而无需执行任何操作,但是您必须捕获它.

That is perfectly possible, you can catch it in the controller without doing anything with it, however you will have to catch it.

这篇关于Laravel可选路由参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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