Laravel Validation
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
if ($validator->fails()) {
$errMsg='';
foreach ($validator->getMessageBag()->toArray() as $key => $value) {
$errMsg.='*'.$value[0]."\r\n";
}
echo json_encode(array(
'success' => 'error',
'errormsg' => $errMsg
));
exit;
}