From 3ac08774183f3385d9dad6adceb53382bb04f887 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 14 Jan 2025 09:50:43 -0800 Subject: [PATCH] remove try/catch, add rules for template --- app/Http/Controllers/SettingsController.php | 4 ---- app/Http/Requests/StoreLabelSettings.php | 1 + app/View/Label.php | 12 ------------ 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 603cc7455c93..e963baaf5cb7 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -798,11 +798,7 @@ public function postLabels(StoreLabelSettings $request) : RedirectResponse $setting->labels_display_model = 0; } - if ($setting->save()) { - if ($setting->label2_template === null) { - return redirect()->route('settings.labels.index')->with('error', trans('admin/settings/message.labels.null_template')); - } return redirect()->route('settings.labels.index') ->with('success', trans('admin/settings/message.update.success')); diff --git a/app/Http/Requests/StoreLabelSettings.php b/app/Http/Requests/StoreLabelSettings.php index a203d2702df7..e11ead8bafaa 100644 --- a/app/Http/Requests/StoreLabelSettings.php +++ b/app/Http/Requests/StoreLabelSettings.php @@ -36,6 +36,7 @@ public function rules(): array 'labels_pagewidth' => 'numeric|nullable', 'labels_pageheight' => 'numeric|nullable', 'qr_text' => 'max:31|nullable', + 'label2_template' => 'required|string', ]; } } diff --git a/app/View/Label.php b/app/View/Label.php index 4faa6ed97efb..27406937dca6 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -50,7 +50,6 @@ public function render(callable $callback = null) ->with('count', $this->data->get('count')); } - try { $template = LabelModel::find($settings->label2_template); if ($template === null) { @@ -58,17 +57,6 @@ public function render(callable $callback = null) } $template->validate(); - } catch (\UnexpectedValueException $e) { - - \Log::error('Validation failed: ' . $e->getMessage()); - - } catch (\Throwable $e) { - - \Log::error('An unexpected error occurred: ' . $e->getMessage()); - - } - - $template->validate(); $pdf = new TCPDF( $template->getOrientation(),