Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove try catch, add validation rules for label template #25

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading