0
votes

Can anyone explain how I redirect to a named route that uses a parameter in the 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. How do I pass the {handle} through?

1
+1 For pointing Route::put. Where did you find it by the way? Laravel Documentation doesn't seems to mention it. I can't figure out completely what '{handle}' does as a parameter in the Route::post. Can you point me in the right direction with a link or a brief explanation? I would appreciate it very much!giannis christofakis
@yannishristofakis 'Put' requests are forged using a hidden field. But, they are managed with forms of type 'POST'.Hakim
@h4k1m Ok I think I'm an idiot or it was to late. When you say '{handle}' you mean the request that the routes handle, it's that right? Yes I know PUT request DELETE,PATCH restful stuff. Thnx, do you know any good source of information, other than the Laravel Documentation to suggest?giannis christofakis
1. Yes '{handle}' represent any request. 2. I think that Nettuts has some good tutorials on laravel.Hakim
Yeah, {handle} is the name of any value passed as a request and would be used in the controller as $handle as far as I know. I put this to bed for a while and I'm only just getting back into Laravel.designermonkey

1 Answers

0
votes

Well I figured it out, that I was missing the $handle in the closure function as a parameter.

I must say, it's great to see the helpful Laravel community at work. So many helpful hints and tips for me here. All these answers just blow me away, thanks so much!