Accessing repeater data
Hi, I implemented repeater on my form. I don't want to change my table column to json type so I was thinking of just iterate each value inside of the repeater data by using
foreach
and apply something on it before saving. How can I access stored repeater data?17 Replies
are you using the admin panel?
Yes
I understand that $data['nameoffield'] can access the repeater but it is stored as an array, and I want to get those data inside of that array and do like foreach to iterate each of that repeater data to my normal fields so that I can save it as normal data.
Like
Field1
Repeater with 2 field
Field2
And I want to do
Field 1
Repeater data [0]1
Field 2
Field 1
Repeater data [1]1
Field 2
i dont understand
the mutate function is probably what youre looking for though
I just want to access the repeater array data
when?
My form modal looks like this
And I want to access this data
So that I can use foreach to iterate those data
And save it just like
When saving, Im gonna use
mutateFormDataUsing()
so that I can manipulate the data, before saving it to the database
Yes, Im using mutateFormDataUsing()
Probably afterCreate/afterSave where you access $this->record->relationship()->update([…])
Im sorry, but i dont get what you mean
Filament
Creating records - Resources - Admin Panel - Filament
The elegant TALL stack admin panel for Laravel artisans.
I know hooks and that's not what I needed.
Repeater data are stored on
$data['nameofrepeater]
array. as seen in the screenshot as an array, so, an array inside of the array. What I want to do is access those data inside of repeater array so that I can use a foreach loop to iterate those data into my normal field before saving, as example on the above message.This is the data thats been POST
and I want to access those repeater data so that I can do a foreachloop so that my final data can look like this
Doing
dd ($data['dispensed_medicines']) //name of the repeater
gives me the array of repeater with
I want to get the pharmacy_stocks_id
, is it possible on $data[]
array?$data['dispensed_medicines'][0]['pharmacy_stocks_id']
thanks dan! that do the trick
i was confused because i thought the question was about filament specifically
it might be worth revising your knowledge on PHP arrays
Well, im using filament, and repeater recomment that to store data in a JSON column. I dont want to do that, because, normalization. Im trying that but without the 3rd part so the output was like a single string.
im sorry mybad