Merge pull request #16360 from spencerrlongg/bug/sc-28537
Add Safety Around Bulk Status Update
This commit is contained in:
commit
d923d29bad
1 changed files with 6 additions and 2 deletions
|
@ -358,7 +358,11 @@ class BulkAssetsController extends Controller
|
||||||
* to someone/something.
|
* to someone/something.
|
||||||
*/
|
*/
|
||||||
if ($request->filled('status_id')) {
|
if ($request->filled('status_id')) {
|
||||||
$updated_status = Statuslabel::find($request->input('status_id'));
|
try {
|
||||||
|
$updated_status = Statuslabel::findOrFail($request->input('status_id'));
|
||||||
|
} catch (ModelNotFoundException $e) {
|
||||||
|
return redirect($bulk_back_url)->with('error', trans('admin/statuslabels/message.does_not_exist'));
|
||||||
|
}
|
||||||
|
|
||||||
// We cannot assign a non-deployable status type if the asset is already assigned.
|
// We cannot assign a non-deployable status type if the asset is already assigned.
|
||||||
// This could probably be added to a form request.
|
// This could probably be added to a form request.
|
||||||
|
@ -366,7 +370,7 @@ class BulkAssetsController extends Controller
|
||||||
// Otherwise we need to make sure the status type is still a deployable one.
|
// Otherwise we need to make sure the status type is still a deployable one.
|
||||||
if (
|
if (
|
||||||
($asset->assigned_to == '')
|
($asset->assigned_to == '')
|
||||||
|| ($updated_status->deployable == '1') && ($asset->assetstatus->deployable == '1')
|
|| ($updated_status->deployable == '1') && ($asset->assetstatus?->deployable == '1')
|
||||||
) {
|
) {
|
||||||
$this->update_array['status_id'] = $updated_status->id;
|
$this->update_array['status_id'] = $updated_status->id;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue