I have a Laravel Application, and something strange is happening related to the session variables. I have a method in a controller that checks some inputs and depending of some conditions it decides if continues or just return back (and right here where is my problem), when I make return redirect()->back() I want so send a variable that is a Json, so briefly I have this:
$msg=json_encode([
'status' => 'failed',
'field'=>'mail'
]);
return redirect()->back()->with('msg',$msg);
So, it redirects very well, but then in the view I have:
@if ( Session::has('msg') )
//come stuffs
@endif
But it seems likes the msg variable is not passed. Accodring to the Laravel documentation when one uses redirect back the variables are accesible trough Session
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire