How to change the method of an HTTP request in Laravel 4


I need to perform CRUD operations on certain places in my application that are contained within other forms. For this I will use AJAX to update the views containing the "sub-content".

I'm using the Resource Controllers methods of Laravel 4 to control routes from the standard Framework methods:

To better illustrate the scenario: There is a business register that has n people assigned to this company.

The view cadastro.empresas.edit has a form with company data and within that view I have a div that will work people being updated by AJAX according to CRUD operations.

The problem: When I make a return Redirect::action('[email protected]', array('id' => $pessoa->id)); I need the request method to be GET , but since the original request (update) is a PUT I end up falling into an infinite loop.

How do I indicate which method I want to use when calling a Redirect::action() ?

asked by anonymous 24.04.2014 / 19:13

2 answers


It seems that your problem is not the laravel because the

Redirect::route(', $pessoa->id);

It works normal here in my applications laravel 4.1, your question here is that it is trying to do a redirect inside an AJAX request, who would be expecting just one answer.

Two tips, or you return an "OK" for this request, and after receiving OK you call the show method, or do this implementation, using something like AngularJS or BackboneJS.

03.05.2014 / 20:25

Try to use Redirect::route(', $pessoa->id)

It's easier to maintain and read. I always name my routes, even though I'm not using the resource, and I've never had a problem that looks like the scenario you indicated.

25.04.2014 / 18:43