F
Filamentβ€’7mo ago
Gudao

Customize and export a JSON column

How do you format the JSON values in the database within the exporter file. Im trying to make these values easily readable by the user exporting them
19 Replies
stursby
stursbyβ€’2mo ago
@Gudao I'm trying to do the exact same thing... did you ever find a solution?
Gudao
GudaoOPβ€’2mo ago
I did find something but I didnt fully go into it Lemme just try and get it for you
stursby
stursbyβ€’2mo ago
yea, I saw that... doesn't really do what I need tho... since adding ->listAsJson() just changes the output from: Data one, two, three to Data {'a': 'one', 'b': 'two', 'c': 'three'} and what I'm looking for is: A B C one two three
Bruno Pereira
Bruno Pereiraβ€’2mo ago
keep in mind that the number of columns of the file are the number of columns you choose from the model.
stursby
stursbyβ€’2mo ago
That still only creates one column tho πŸ€·β€β™‚οΈ ie: after export it looks like: Data data.one, data.two, data,three
stursby
stursbyβ€’2mo ago
No description
Bruno Pereira
Bruno Pereiraβ€’2mo ago
Like I said, you wont be able to add columns to the file. Unless you can force a line break, you won't be able to create.
stursby
stursbyβ€’2mo ago
yea, I was just hopind I'd be able to a access the record and do something like this (just some sample pseudocode)
stursby
stursbyβ€’2mo ago
No description
stursby
stursbyβ€’2mo ago
πŸ€·β€β™‚οΈ
Bruno Pereira
Bruno Pereiraβ€’2mo ago
you can pass the eloquent model to the function it says in the docs
stursby
stursbyβ€’2mo ago
hmmm where did you see that?? do you mean getting the model inside the ExportColumn function? Ideally I'd be able to get it one level higher inside of getColumns but I haven't found a way to successfully do that yet
stursby
stursbyβ€’2mo ago
yea, that just formats that one column... I want to generate multuple dyanmic culums from one JSON column in the DB
Bruno Pereira
Bruno Pereiraβ€’2mo ago
I dont think thats possible using the in built export action
stursby
stursbyβ€’2mo ago
got it, yea, that's kinda what it looks like I know it's an odd use case... but I'm making a "Form Builder" so the client can use the Filament Builder to generate custom Forms that's all stored in the data column so when they want to Export the form submissions... Ideally the key/values in data would get mapped to CSV colums/values
khairulazmi_
khairulazmi_β€’6d ago
Hi . did you happen to figure out how to do this ?
Want results from more Discord servers?
Add your server