Advanced Livewire: A better way of working with models

By @samuel · 2021-10-11 21:08

Advanced Livewire: A better way of working with models

  • By @samuel · 2021-10-14 13:18

    Using a package if of course totally fine, but why didn't you just make the attribute private?

    Because then it wouldn't be persistent. If we set the value in mount(), but keep the property private, it won't be included in the payload sent to the frontend, and when Livewire rehydrates the component on the next request, the property won't have any value.

    That's the point of the package — we need to include the data in the payload, but we also need to avoid frontend modifications.