2

I have a named route

Route::get('login/facebook', array(
      'as'   > 'login.facebook.authorise', 
      'uses' => 'AuthController@getFBAuthorise'
));

and want to produce a URL pointing to it with a query string appended.

For example:

URL::route('login.facebook.authorise', array("next"=>'/dashboard/')

would produce

/login/facebook?next=/dashboard/

Is something like this built in to the framework? If not, what is the best way to try and do this?

Thanks.

4

3 回答 3

1

我参加聚会有点晚了

只需深入研究用于构建 url 的类和方法,您就可以这样做:

link_to_route('login.facebook.authorise','Facebook Login',array('next'=>'/Dashboard/'))

所以。除非在路由中声明了名称,否则数组将始终回退到查询参数。

于 2013-11-27T05:05:57.893 回答
1

URL 助手可以做到这一点。

http://laravel.com/docs/helpers#urls

echo link_to_route('route.name', $title, $parameters = array(), $attributes = array());

编辑:仅获取 URL:

http://laravel.com/docs/routing#named-routes

$url = URL::route('route.name', $parameters);

于 2013-06-20T14:30:57.483 回答
0

如果此用例在登录后重定向到页面,那么您可以使用

Redirect::intended('dashboard');

如此处所示http://laravel.com/docs/security#authenticating-users

抱歉,如果这不是您想要达到的目标。

于 2013-06-20T16:57:01.223 回答