I am a beginner in laravel. I am trying to pass a parameter from middleware from controller like this:
if(isset($_COOKIE['name']))
{
return $next($request->attributes->add(['name' => strval($_COOKIE['name'])]));
}
However, I got this error message:
"Type error: Argument 1 passed to Symfony\Component\HttpFoundation\Response::prepare() must be an instance of Symfony\Component\HttpFoundation\Request, null given"
I tried to convert the cookie value as string before passing it, but it did not work. How can I pass the pass the cookie as parameter? I do not want to get the value of cookie using $_COOKIE['name']
. My laravel version is 5.5. Thank you!