From 91b1cc7121e1e4b7538d43e1e95325732cd889a6 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 5 Sep 2023 13:23:51 -0600 Subject: [PATCH] Move the early return to the controller instead of the Label model --- app/Http/Controllers/Assets/BulkAssetsController.php | 8 +++++++- app/View/Label.php | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index a744db5788..932176286f 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -58,8 +58,14 @@ class BulkAssetsController extends Controller switch ($request->input('bulk_actions')) { case 'labels': $this->authorize('view', Asset::class); + $assets_found = Asset::find($asset_ids); + + if ($assets_found->isEmpty()){ + return redirect()->back(); + } + return (new Label) - ->with('assets', Asset::find($asset_ids)) + ->with('assets', $assets_found) ->with('settings', Setting::getSettings()) ->with('bulkedit', true) ->with('count', 0); diff --git a/app/View/Label.php b/app/View/Label.php index bbba1605b7..d581548eb3 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -39,10 +39,6 @@ class Label implements View $assets = $this->data->get('assets'); $offset = $this->data->get('offset'); $template = $this->data->get('template'); - - if ($assets->isEmpty()){ - return redirect()->back(); - } // If disabled, pass to legacy view if ((!$settings->label2_enable) && (!$template)) {