Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[7.1.2] Laravel 7 component syntax broken with models #715
After updating to Laravel 7.1.2 which shipped laravel/framework@ae4d790 it doesn't seem to be possible anymore to pass models to blade components because they are turned into JSON which results in a string being passed to the mount method of a component.
Using the old
This isn't directly a Livewire issue but the documentation contains examples that make usage of models which obviously is a common use-case. Should this simply be documented or should Livewire provide a workaround to work with models and the new component syntax? @calebporzio
I came here yesterday suspecting the same thing, but didn't see anything about it.
I was questioning whether or not I was using livewire correctly. After a bit of back and forth and more than a little wasted time, I realized that I had updated my composer dependencies. I thought maybe something in livewire changed, but that wasn't the case.
Anyway, today I ran my code, which failed for the same reasons @faustbrian mentioned. Reverting my composer packages (laravel/framework 7.1.2 -> 7.1.0) allowed the code to work again.
Not sure that this is a livewire issue or not, but it needs to be addressed one way or another...especially if laravel/framework 7.1.2 closes some security holes.
@calebporzio Not sure this helps much, but this is what I saw the other day: https://blog.laravel.com/security-laravel-712-released
What @telkins linked is the official information from Taylor and the PR/commit. I think the issue affects us much as it does Laravel, which would be when developers pass around user input without any checks into blade components.
I am not entirely sure though why
So I am not sure if we should just add some information to the Livewire documentation that you should use
// works @component('something', ['model' => $model]) // works @livewire('something', ['model' => $model]) // does not work anymore <x-something :model="$model" /> // does not work anymore <livewire:something :model="$model" />
I think this might be related, so I hope it's OK to post here.
I found that I had to revert back to LiveWire 1.0.4 (using Laravel 7.1.3) to get
<input class="ml-3 my-1 w-48" wire:model="search" type="text" placeholder="Search..." >
This would only pass NULL when using LiveWire above version 1.0.4.
Please feel free to move to it's own issue, if not related.