samedi 28 novembre 2015

Modify input in laravel middleware

Some service makes HTTP request to my site and passes some input. This input has a little bit wrong structure for me, so I'm trying to modify it.

I made a middleware and attached this middleware to my route. The handle method looks like this:

public function handle($request, Closure $next)
{
    $input = $request->all();

    // Input modification

    $request->replace($input);
    \Log::info($request->all()); // Shows modified request

    return $next($request);
}

However in my controller I got old input. Also I'm a little bit confused since I also use FormRequest, and as I realize these two requests are different entities. Then how can I modify the input in the middleware?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire