F
Filament3mo ago
Sean

Help with Builder - no JSON

I am trying to use the Builder without JSON data. I want to use my existing eloquent relationships for the underlying builder. Is this possible? I tried to create a method on my model to return JSON that is a representation of the underlying database data but it doesn't seem to be recognizing that method. I think it is only pulling from the database a column name that matches the Builder::make("insert field here"). Is what I am after possible? Or am I going to have to change the database architecture of my app?
4 Replies
MilenKo
MilenKo3mo ago
I am not an expert in Filament to be honest but I think you've answered your question already with your latest statement as the builder uses the input name you defined in the static make() method. There has to be a way to manipulate maybe that, but for me this will be a high end acrobatics that I cannot assist much with (or not yet as I am just trying to go along with Filament and all it's magic tricks and abilities under the hood)
awcodes
awcodes3mo ago
The builder field is built around the idea of json structured data, ie each block needs to have specific keys to know how to generate the state path. So, it might be possible with a relationship as long as the related model has the right structure but you would still need to hydrate and dehydrate the builder state into an array in a way that the builder understands.
Sean
SeanOP3mo ago
@awcodes - that makes sense. how can i read up on how to hydrate/dehydrate the builder? I thought i could pass it a method from my model class since its a Filament Resource for that model, but it doesn't seem to care that I am passing it a method from the model. It looks like it is trying to go straight to the database. I just don't know how to hijack it to hydrate/dehydrate it.
Want results from more Discord servers?
Add your server