ok, this works except error display

This commit is contained in:
slong753 2023-04-26 15:06:50 -05:00
parent 6bec9cf880
commit 52c9fefbe0

View file

@ -187,11 +187,11 @@ class BulkAssetsController extends Controller
}
$changed = [];
$asset = Asset::where('id' ,$assetId)->get();
$assetCollection = Asset::where('id' ,$assetId)->get();
foreach ($this->update_array as $key => $value) {
if ($this->update_array[$key] != $asset->toArray()[0][$key]) {
$changed[$key]['old'] = $asset->toArray()[0][$key];
if ($this->update_array[$key] != $assetCollection->toArray()[0][$key]) {
$changed[$key]['old'] = $assetCollection->toArray()[0][$key];
$changed[$key]['new'] = $this->update_array[$key];
}
}
@ -219,17 +219,16 @@ class BulkAssetsController extends Controller
$asset->save();
}
if (!$asset->save()) {
$error_bag[] = $asset;
$error_bag[] = $asset->getErrors();
}
}
if (!$asset->save()) {
return redirect()->back()->withInput()->withErrors('One of your custom fields is not valid.');
}
} else {
Asset::find($assetId)->update($this->update_array);
}
} // endforeach ($assets)
if(!empty($error_bag)) {
return redirect($bulk_back_url)->withErrors($error_bag);
}
return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.update.success'));
}
// no values given, nothing to update