Added validation part for generate pdf #39

Merged
jothi merged 1 commits from ranjith-dev into master 2025-12-22 12:19:39 +00:00

View File

@@ -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());
}