Skip to content

helpers to_route: new return type breaks the function in Livewire components #56858

@ghbob

Description

@ghbob

Laravel Version

12.26.4

PHP Version

8.4

Database Driver & Version

No response

Description

I use to_route in Livewire components, with the new return type this no longer works.

to_route(): Return value must be of type Illuminate\Http\RedirectResponse, Livewire\Features\SupportRedirects\Redirector returned

Change was:

function to_route($route, $parameters = [], $status = 302, $headers = []): RedirectResponse

from 6d5dfad

@calebdw You just took it from the PHPDoc and "promoted" it to a return type, I assume?

I'll switch to Livewire $this->redirectRoute(), probably cleaner anyway, but since https://livewire.laravel.com/docs/redirecting mentions:

If you prefer, you can use Laravel's built-in redirect utilities within your components as well.

I thought I'd at least create this issue so someone else with the same problem can find something.
I'm not sure how Livewire handles these but it definitely worked before.

Thanks!

Steps To Reproduce

use to_route() in a Livewire component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions