Redirect if no assets are returned from query

This commit is contained in:
Marcus Moore 2024-03-07 12:30:08 -08:00
parent 806671df7c
commit f270f30728
No known key found for this signature in database
2 changed files with 7 additions and 0 deletions

View file

@ -14,6 +14,7 @@ use App\View\Label;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
use App\Http\Requests\AssetCheckoutRequest; use App\Http\Requests\AssetCheckoutRequest;
use App\Models\CustomField; use App\Models\CustomField;
@ -95,6 +96,11 @@ class BulkAssetsController extends Controller
$assets = $assets->get(); $assets = $assets->get();
if ($assets->isEmpty()) {
Log::debug('No assets were found for the provided IDs', ['ids' => $asset_ids]);
return redirect()->back()->with('error', trans('admin/hardware/message.update.assets_do_not_exist_or_are_invalid'));
}
$models = $assets->unique('model_id'); $models = $assets->unique('model_id');
$modelNames = []; $modelNames = [];
foreach($models as $model) { foreach($models as $model) {

View file

@ -19,6 +19,7 @@ return [
'success' => 'Asset updated successfully.', 'success' => 'Asset updated successfully.',
'nothing_updated' => 'No fields were selected, so nothing was updated.', 'nothing_updated' => 'No fields were selected, so nothing was updated.',
'no_assets_selected' => 'No assets were selected, so nothing was updated.', 'no_assets_selected' => 'No assets were selected, so nothing was updated.',
'assets_do_not_exist_or_are_invalid' => 'Selected assets cannot be updated.',
], ],
'restore' => [ 'restore' => [