Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Livewire and serialization

Hello,

In the Livewire documentation, there are examples using Livewire forms where you can pass the entire model to the form.

But given that there is a serialization that doesn't keep hidden fields hidden and so exposes all the fields, is it a good idea to pass the entire model or is it preferable to pass only the id and get the model instance via a query ?

If I'm right, shouldn't the documentation be updated with safer examples ?

Thanks for your answer ;).

V

0 likes
2 replies
Batman55's avatar
Batman55
Best Answer
Level 32

I would only pass the necessary information. I tend to use Resource for stripping/passing only necessary model information, and limiting database calls to only return the information needed.

I do not know how livewire works in this senario, but blade (in my understanding) only passes the information actually used. Inertia doesn't discriminate in the info it passes.

Maybe showing some age, but I do not like passing any information that is not actually needed. Back when we still had a majority on dial up and slow bandwidth services, payloads needed to be as slim as possible. I've kept that throughout the last 25 years and personally find it very bad practice to send unneeded information like full models if I only need an id or name property when possible.

Yes, if you are correct, docs should be updated!

1 like

Please or to participate in this conversation.