$exceptions = [];
foreach ($input as $value) {
try {
$output = Model::firstOrCreate($value);
} catch (Exception $e) {
$exceptions[] = $e->getMessage();
}
}
return response()->json(['error' => json_encode($exceptions)], 400);
<?php
echo <<<'TAG'
<script>
document.addEventListener("DOMContentLoaded", function () {
var error_porl = document.getElementById("error_porl");
if (error_porl)
{
error_porl.style.display = 'block';
}
});
</script>
TAG;
?>