Skip to content

Commit

Permalink
Merge pull request #25 from Godmartinz/template_validate_error_p2
Browse files Browse the repository at this point in the history
remove try catch, add validation rules for label template
  • Loading branch information
Godmartinz authored Jan 14, 2025
2 parents 0118504 + 3ac0877 commit dd08642
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 16 deletions.
4 changes: 0 additions & 4 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
1 change: 1 addition & 0 deletions app/Http/Requests/StoreLabelSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
}
}
12 changes: 0 additions & 12 deletions app/View/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,13 @@ public function render(callable $callback = null)
->with('count', $this->data->get('count'));
}

try {
$template = LabelModel::find($settings->label2_template);

if ($template === null) {
return redirect()->route('settings.labels.index')->with('error', trans('admin/settings/message.labels.null_template'));
}

$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(),
Expand Down

0 comments on commit dd08642

Please sign in to comment.