G
G
ganjo8882019-11-29 13:32:10
Laravel
ganjo888, 2019-11-29 13:32:10

How to pass request to middleware?

There are two middlewares
here, I want to convert some data and pass it to the next middleware, how do I send $content so that the request reaches the middleware trail?

class ConverterMiddleware
{
    public function handle($request, Closure $next)
    {
        $content = json_decode($request->getContent(), true);

        $content = $this->convertDate($content);

        return $next($content);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Kulaxyz, 2019-11-29
@ganjo888

Pass Request $request
AND in middleware either change existing parameters or add new ones like this:
$request->request->add(['variable' => 'value']);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question