This commit is contained in:
slong753 2023-05-03 14:49:31 -05:00
parent cdda4a56d8
commit 815c77f943
2 changed files with 28 additions and 9 deletions

View file

@ -223,7 +223,7 @@ class BulkAssetsController extends Controller
$asset->save();
}
if (!$asset->save()) {
$error_bag[] = $asset->getErrors();
$error_bag[] = $asset->getErrors()->toArray();
}
}
} else {
@ -231,14 +231,18 @@ class BulkAssetsController extends Controller
}
} // endforeach ($assets)
if(!empty($error_bag)) {
$ids = array_values($assets);
// dd($ids);
// return redirect()->back()
// ->withInput(["ids" => $ids, "bulk_actions" => "edit"])
// ->with('error_messages', $error_bag);
// return $error_bag;
return redirect($bulk_back_url)->with('error_messages', $error_bag);
// $errors = collect($error_bag)->unique();
// foreach ($errors as $key => $value) {
// ray($value->message);
// }
$errors = [];
foreach ($error_bag as $key => $value) {
foreach($value as $key => $value) {
$errors[] = $value;
}
}
ray($errors);
return redirect($bulk_back_url)->with('bulk_errors', $errors);
}
return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.update.success'));
}

View file

@ -115,6 +115,21 @@
@endif
@if ($messages = Session::get('bulk_errors'))
<div class="col-md-12">
<div class="alert alert alert-danger fade in">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<i class="fas fa-exclamation-triangle faa-pulse animated"></i>
<strong>{{ trans('general.notification_error') }} </strong>
The following fields had validation errors and were not edited:
@foreach($messages as $message => $value)
<br> {{ $value. }}
@endforeach
</div>
</div>
@endif
@if ($message = Session::get('warning'))
<div class="col-md-12">
<div class="alert alert-warning fade in">