Livewire: 7.4 Typed Properties & Route Param Binding

Created on 28 Aug 2020  路  2Comments  路  Source: livewire/livewire

This is an outline for two Livewire features:

#1: Directly assign properties from route parameters without the mount() method:

Route::get('/post/{post}, ShowPost::class)
class ShowPost extends Component
{
    public Post $post;

    // Notice no mount method needed.
}



md5-c1e67e92f927508a51f8aaf14fb52906



```php
class ShowPost extends Component
{
    public Post $post;

    public function changePost(Post $newPost)
    {
        $this->post = $newPost;
    }
}

A user visits /post/1, and then clicks a Livewire button that calls "changePost(2)", the URL now says /post/2 without ever changing pages. (using pushState).

This should work with ANY route parameters no matter if they are route model bound or not.

Most helpful comment

Just tested it AWESOME!!!

All 2 comments

We just had a long call with @calebporzio, @inxilpro and myself about these features and we're going to be implementing them on our end.

Just tested it AWESOME!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bardh7 picture bardh7  路  3Comments

randohinn picture randohinn  路  3Comments

cloudstudio picture cloudstudio  路  3Comments

tanthammar picture tanthammar  路  3Comments

roni-estein picture roni-estein  路  3Comments