如何通过URL在Laravel中传递布尔值?
我需要传递像“
?
Route::get('/link/page', 'TestController@index')->defaults('_config', [
'view' => 'test::home.page.index'
])->name('test.home.page.index');
I need to pass a param like "link/page?url=true" or "link/page?url=false"
How can I set it in my route file?
Route::get('/link/page', 'TestController@index')->defaults('_config', [
'view' => 'test::home.page.index'
])->name('test.home.page.index');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果参数将是一个查询参数,则无需在路由文件中定义它。在控制器中,您可以获取参数:
但是,如果您真的希望参数作为URL本身的一部分,那么您可以这样定义它:
要在控制器中获取它,您必须执行此操作:
If the param is going to be a query parameter, then there is no need to define it in the Route file. In the controller you can fetch the param as:
But if you really want the parameter to part of the URL itself then you can define it like this:
and to fetch it in controller you have to do this: