【问题标题】:Specifying a route name in Redirect::intended在 Redirect::intended 中指定路由名称
【发布时间】:2014-09-30 00:14:29
【问题描述】:

我想通过名称获取路由值并将其存储在变量中。

原因是,我想使用 Redirect::intended($url) 方法将用户重定向到路由,而不是仅仅将 url 放在那里。

基本上,我希望具有与 Redirect::route($route_name) 相同的行为,但使用预期的()函数。

有没有类似 Route::getValueByName() 的方法?

非常感谢。

【问题讨论】:

  • 您想将当前路由名称作为intended 的默认值传递吗?
  • 假设我有以下路线: Route::get('/', ['as' => 'home', 'uses' => 'BaseController@index']);我想使用 Redirect::intended('home')

标签: php laravel laravel-routing


【解决方案1】:

如果我猜对了,你可以使用

Redirect::intended(route('home'));

或

Redirect::intended('/');

甚至

Redirect::intended(action('BaseController@index'));

【讨论】:

  • 太棒了!非常感谢。
猜你喜欢
  • 1970-01-01
  • 2013-10-04
  • 2014-07-20
  • 2018-05-16
  • 2023-03-07
  • 2019-10-07
  • 2019-01-23
  • 2017-04-16
  • 2017-09-23
相关资源
最近更新 更多