diff --git a/app/Http/Controllers/PdfController.php b/app/Http/Controllers/PdfController.php index c56bd20..d3915b2 100644 --- a/app/Http/Controllers/PdfController.php +++ b/app/Http/Controllers/PdfController.php @@ -9,6 +9,7 @@ use App\Models\ProcessOrder; use App\Models\StickerStructureDetail; use App\Models\User; use App\Services\StickerPdfService; +use Filament\Notifications\Notification; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Response; @@ -895,9 +896,21 @@ class PdfController extends Controller public function generate(string $stickerId) { + $stickerId = trim($stickerId); + $elements = StickerStructureDetail::where('sticker_id', $stickerId) ->first(); + if (!$elements) { + Notification::make() + ->title('Sticker not found') + ->body("Sticker ID '{$stickerId}' does not exist.") + ->danger() + ->send(); + + return; + } + $pdfService = new StickerPdfService(); return $pdfService->generate($stickerId, $elements->toArray()); }