In the Laravel 5.2
, all routes must pass through the group of middleware called web
.
What happens is that in some releases of Laravel 5.2
, the settings of RouteServiceProvider
is as follows:
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace, 'middleware' => 'web'], function ($router) {
require app_path('Http/routes.php');
});
}
Note that there is already declared that all the routes you create within Http/routes.php
shall have the settings set out in $router->group
. In your case, we verify that you’re like this, so when you made your statement ['middleware' => ['web','auth']
, you’re making this one middleware
be sued again.
Incredible as it seems, the Middleware group web
is responsible for pre-processing the session.
When you talk about "no error is being displayed", you are probably talking about the validation errors, which use the MessageBag
, who in turn use the Session Flash
.
The Flash
is created only once, and when it is accessed, it is removed. If you call the middleware
twice because of the redeclaration, it is obvious that in the second call the Session Flash
will cease to exist.
So the solution to your problem is simply to remove web
of your array
, being like this:
['middleware' => ['auth']
With that we can solve the problem.
It is worth noting that in some versions of Laravel 5.2
, this method does not come with the web middleware, it is necessary to add either in the Route Group declaration or in the Routeserviceprovider declaration.
In my project for example, it’s like this:
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function ($router) {
require app_path('Http/routes.php');
});
}
It sends the error there. By number I do not know what it is. It has to do with the CSFR Token ?
– Diego Souza
302 is "temporarily moved" not knowable enough to answer the question they use this code to answer a request.
– Rafael Mena Barreto
Put the contents of your controller and Routes, it may also be that when accessing
usuario/salvar
he directs tousuario/salvar/
and so you see this message, I recommend you read this: http://answall.com/help/mcve– Guilherme Nascimento
@Guilhermenascimento did not put the details of the error. I work with him, and slapped the question, to better describe the problem
– Wallace Maxters
@Wallacemaxters takes advantage that you are close to him and slap him on the head to read the MCVE ... Fun :p --- Nice to know that you work together.
– Guilherme Nascimento
kkkkkkkkkkkkkkkkk
– Miguel Batista