简体   繁体   English

Laravel:重定向到在URL中具有参数的命名路由

[英]Laravel: Redirect to a named route that has parameters in URL

Can anyone explain how I redirect to a named route that uses a parameter in the URL? 谁能解释我如何重定向到使用URL中的参数的命名路由?

I have the following code: 我有以下代码:

    Route::put('{handle}', array(
        'as' => 'section.update',
        'uses' => 'Manneken\\Api\\SectionManager@update'
    ));

    Route::post('{handle}', function()
    {
        if (Input::has('method') && Input::get('method') === 'PUT') {
            Redirect::route('section.update', array(
                'handle' => ''
            ))->withInput();
        }
    });

So, I have a route using PUT that has {handle} in the URL, and if requested by POST, I want to redirect to that route. 因此,我有一个使用PUT的路由,该路由的URL中有{handle} ,如果POST请求,我想重定向到该路由。 How do I pass the {handle} through? 如何通过{handle}

Well I figured it out, that I was missing the $handle in the closure function as a parameter. 好吧,我发现,我在闭包函数中缺少$handle作为参数。

I must say, it's great to see the helpful Laravel community at work. 我必须说,很高兴见到有用的Laravel社区在工作。 So many helpful hints and tips for me here. 这里有很多对我有用的提示和技巧。 All these answers just blow me away, thanks so much! 所有这些答案都让我震惊,非常感谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM