I'm trying to pass a value on failed validation in Laravel.
I tried this, but couldn't get the output.
if ($validation->fails()) {
$errorflag=1;
return Redirect::back()->withInput()->withErrors($validation)->with('errorflag', $errorflag);
}
I tried to get this value in the view using just a isset() check
<?php
if(isset($errorflag)){
echo $errorflag;
}
?>
But I'm unable to get the output even though I made a validation error in the form. How can I do this?