Search code examples
laravellaravel-livewire

Livewire 3 #[Url] Attribute


I am creating a datatable that tracks multiple properties with the #[Url] attribute.

    #[Url]
    public string $search = '';

    #[Url]
    public array $sorts = [];

    #[Url]
    public int $perPage = 15;

When I modify any of these properties they are updated in the URL as expected. The issue is when I send a link to another user.

Let's use this URL for example: website.com/search=123&sorts[created_at]=asc&perPage=25

When we hit enter it will set all (3) properties correctly but will remove everything except ?search=123 from the URL. Regardless of everything I have tried search always works and no other property will work with #[Url] attribute.

Any ideas what could be the issue?


Solution

  • It could depend on how the properties are valued.

    Try using #[Url(except: '')] instead of #[Url], it should work.
    Here the documentation