I want to return an error message using Sweet alert going through my Laravel controller.
Controller
public function update(TenderRequest $request,$id)
{
$tender = TenderMaster::findOrFail($id);
if($request->extend_date < $request->end_date){
//Return error message here
}
}
Sweet Alert Function:
error: function (data) {
var errors = data.responseJSON;
//console.log(errors.message.errors);
$.each(errors.errors,function (k,v) {
Swal.fire({
title: 'Error!',
html:
'<h4><code>' + v + '</code></h4>',
confirmButtonText: 'Close',
confirmButtonColor: '#d33',
})
});
}
Try like this...
return Response::json([('status' => 'success','data'=>'data')]);