Hello, everyone
I’m having a hard time both understanding and finding clear, unambiguous information on how to represent a model with Livewire.
I want to render multiple Eloquent models with 2 text fields (‘l’ and ‘r’). Each text field would be a text area editable through tinyMCE. If any of the fields have changes, a “save changes” button should be displayed. I’m honestly having too much trouble trying to figure out how this should be done.
-
Should I save the Eloquent model itself as a variable (
public $model;
) or the fields (public $l; public $r;
) inside the Livewire class? -
Let’s ignore tinyMCE for a minute and assume ‘l’ and ‘r’ are basic text areas. How should
wire:dirty
be used?
2.1) In case the eloquent model is stored as a variable, should I usewire:target="model"
? Or should I pointwire:target
to the attribute(s) I’d like to check for changes?
2.2) In case each attribute is stored as its own variable, how can I check if any of the variables is dirty?wire:target="l" wire:target="r"
?
I’m sorry if these are basic questions that have been answered somewhere; I’ve spent a few hours trying out most possibilities and reading the docs and any tutorials I could find (hardly any of them decent), and I just can’t wrap my head around what Livewire’s best practices are supposed to be.