ok, this kind of works - pr needs some clean up

This commit is contained in:
slong753 2023-06-26 14:56:07 -05:00
parent f646623a5e
commit 691faf6340
2 changed files with 18 additions and 12 deletions

View file

@ -253,23 +253,29 @@ class BulkAssetsController extends Controller
Asset::find($assetId)->update($this->update_array);
}
} // endforeach ($assets)
ray($error_bag);
ray(['error_bag1' => $error_bag]);
if(!empty($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;
//find the customfield name from the name of the messagebag items
foreach ($error_bag as $key => $bag) {
ray($bag->keys());
foreach($bag->keys() as $key => $value) {
CustomField::where('db_column', $value)->get()->map(function($item) use (&$errors) {
$errors[] = $item->name;
});
}
}
ray($error_bag);
Session::save('ids', $assets);
}
ray(['error_bag2' => $errors]);
// Session::save('ids', $assets);
// return redirect()->route('hardware/bulkedit');
return redirect()->back()->with('bulk_errors', $errors);
return redirect($bulk_back_url)->with('bulk_errors', array_unique($errors));
}
return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.update.success'));
}

View file

@ -115,19 +115,19 @@
@endif
{{-- @if ($messages = Session::get('bulk_errors'))
@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. }}
@foreach($messages as $message)
<br> {{ $message }}
@endforeach
</div>
</div>
@endif --}}
@endif
@if ($message = Session::get('warning'))