Skip to content

Commit d6e266c

Browse files
committed
make super safe
1 parent 31516d7 commit d6e266c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/Http/Controllers/Assets/BulkAssetsController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,19 @@ public function update(Request $request) : RedirectResponse
358358
* to someone/something.
359359
*/
360360
if ($request->filled('status_id')) {
361-
$updated_status = Statuslabel::find($request->input('status_id'));
361+
try {
362+
$updated_status = Statuslabel::findOrFail($request->input('status_id'));
363+
} catch (ModelNotFoundException $e) {
364+
return redirect($bulk_back_url)->with('error', trans('admin/statuslabels/message.does_not_exist'));
365+
}
362366

363367
// We cannot assign a non-deployable status type if the asset is already assigned.
364368
// This could probably be added to a form request.
365369
// If the asset isn't assigned, we don't care what the status is.
366370
// Otherwise we need to make sure the status type is still a deployable one.
367371
if (
368372
($asset->assigned_to == '')
369-
|| ($updated_status->deployable == '1') && ($asset->assetstatus->deployable == '1')
373+
|| ($updated_status->deployable == '1') && ($asset->assetstatus?->deployable == '1')
370374
) {
371375
$this->update_array['status_id'] = $updated_status->id;
372376
}

0 commit comments

Comments
 (0)