FilamentF
Filament3y ago
eazy

Redirect in listener

Hello, I'm making a custom listener to download a PDF when someone clicks on a button.
The PDF gets generated on a URL so I want to redirect the user to the url when they click on the button. But it doesn't work.
This is the current code:
$this->registerListeners(['repeater::downloadItem' => [
            function (Repeater $component, string $statePath, string $idToDownload) {
                if ($statePath !== $component->getStatePath()) {
                    return;
                }

                $record = $component->getRecord();
                $id = Str::after($idToDownload, '-');

                return redirect()->route('requests.pdf', [$record, false, [$id]]);
            }
        ]]);
Was this page helpful?