ok, this works except error display
This commit is contained in:
parent
6bec9cf880
commit
52c9fefbe0
1 changed files with 7 additions and 8 deletions
|
@ -187,11 +187,11 @@ class BulkAssetsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$changed = [];
|
$changed = [];
|
||||||
$asset = Asset::where('id' ,$assetId)->get();
|
$assetCollection = Asset::where('id' ,$assetId)->get();
|
||||||
|
|
||||||
foreach ($this->update_array as $key => $value) {
|
foreach ($this->update_array as $key => $value) {
|
||||||
if ($this->update_array[$key] != $asset->toArray()[0][$key]) {
|
if ($this->update_array[$key] != $assetCollection->toArray()[0][$key]) {
|
||||||
$changed[$key]['old'] = $asset->toArray()[0][$key];
|
$changed[$key]['old'] = $assetCollection->toArray()[0][$key];
|
||||||
$changed[$key]['new'] = $this->update_array[$key];
|
$changed[$key]['new'] = $this->update_array[$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,17 +219,16 @@ class BulkAssetsController extends Controller
|
||||||
$asset->save();
|
$asset->save();
|
||||||
}
|
}
|
||||||
if (!$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 {
|
} else {
|
||||||
Asset::find($assetId)->update($this->update_array);
|
Asset::find($assetId)->update($this->update_array);
|
||||||
}
|
}
|
||||||
} // endforeach ($assets)
|
} // 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'));
|
return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.update.success'));
|
||||||
}
|
}
|
||||||
// no values given, nothing to update
|
// no values given, nothing to update
|
||||||
|
|
Loading…
Add table
Reference in a new issue