I store some data in a middleware as following:
public function handle($request, Closure $next)
{
//checking above..
if($this->authed()){
$request->token= $token; //here store the token in user request
return $next($request);
}
return response('Invalid credentials', 401);
}
then in controller I call a custom request class
//function in controller
public function upload(CoverageValueRequest $request){ //calling a custom request
dd($request->token);
dd($request->all());
}
the first dd will give null. However if I changed CoverageValueRequest to Request it will print the token.
P.S: the $request data coming from REST call as JSON format using Content-Type: application/json. I am not sure if this is relevant.
update
I have changed the following in the middleware still same behavior:
$request->merge(['token' => $token]);
can't get the token if CoverageValueRequest but if it is Request then it works.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1U1xsyL
via IFTTT
Aucun commentaire:
Enregistrer un commentaire