Hello all,
I’m fairly new to Livewire, so I’m not sure if it’s a bug or something that I’ve missed but I’m experiencing a rather weird behaviour with a wire:model databinding to a model propertie:
I’m editing a Comment (with a text property) which belongsTo a Post. In the component I have a public Comment $comment;
and in my Blade template (in an Edit modal , actually) I have an <input wire:model="comment.text">
.
Everything works fine at first: a dd($this->comment);
shows 5 attributes ["id", "text", "post_id", "created_at", "updated_at"]
But as soon as I’ve modified the text and I’m trying to save that, the same dd($this->comment);
now shows 6 attributes ["id", "text", "post_id", "created_at", "updated_at", "post"]
. The last post attribute being an array (with all the attributes of the corresponding Post).
And when calling $this->comment->save()
the app breaks on an:
Illuminate\Database\QueryException
SQLSTATE[HY000]: General error:1 no such column: post
It seems to me that wire:model messed something there, creating an attribute that shouldn’t be there (and if we were to access $comment->post, we should get a Post model and not an array anyway).
I’ve upgraded to the last version of Laravel and Livewire.
Any idea on the what or why ? Thanks in advance.