Laravel 5为特定链接创建路线 [英] Laravel 5 making a route for a specific link
问题描述
我有一个指向
是否可以为我厌烦的这种链接建立一条路线,但它不起作用
Is it possible to make a route for that kind of link i tired below route but it does not work
Route::get('/pages/vehicles?show={id}', ['middleware' => ['roles'], 'uses' => 'PagesController@show', 'roles' => ['Admin']]);
推荐答案
我尝试将表单直接发送到路线时也遇到了类似的问题(使用类似/pages/vehicles/61之类的方法),但这似乎是不可能的(此处是问题).
I had a similar problem trying to send a form directly to a route (using something like /pages/vehicles/61) but it seems to be imposible (question here).
如果您没有针对所有车辆的特定路线(/页面/车辆未显示车辆列表),则可以执行以下操作:
If you don't have a specific route for all vehicles (/pages/vehicles doesn't show a list of vehicles) you can do something like:
Route::get('pages/vehicles','PagesControler@show');
在您的控制器内部
$show = Request::input('show');
,然后您需要执行任何操作.否则,会像我或javascript一样出现"hack"(我假设您是从表单发送此信息).
and then whatever you need to do with that. Otherwise, a "hack" like I did or javascript (I'm assuming you are sending this from a form).
这篇关于Laravel 5为特定链接创建路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!