handleRecordUpdate
Hi, I'm trying to get the relation data within the handleRecordUpdate
It's a resource page, not a modal... but I don't know how do I get the relationship data:
Can anyone help ? thanks!
17 Replies
up
up
anyone?
What exactly are you trying to do and what is your ultimate goal?
Does your model have the right relation?
Have you read the docs : https://filamentphp.com/docs/3.x/forms/fields/repeater#integrating-with-an-eloquent-relationship
What have you already tried?
Hi @Tieme , thanks for answer, I'm just trying to get the relationship data in the handleRecordUpdate() located in the ResourceEdit class ( in the code I posted above you can see I'm implementing the
->relationship() method
The right side of the form (in the attached picture) is the relation (orderItems) called items() in my model relation, but I just can't get that data to mutate it before save
does that make sense ?
Can you show me the output of
dd($record->toArray(), $data);
?is just not showig the data in the repeater :/
Can you add below code, and show me the output I'm curios if the relation data is in array before save
Can you show me the complete resource via gist : https://gist.github.com/
why do you need the data there if it gets saved for you anyway?
you can try ->dehydrated() on that component, but please think about if you really need it
I need the quantities per product to be able to make some operations against the inventory, so if you edit the product and increase the quantities, then the inventory will decrease (I already did this case ) but if you decrease the quantities in the orderEdit then the inventory will increase, to be able to do that I need the new quantity and compare it to the old one
Personaly for that usecase i will use a model observer.
https://laravel.com/docs/10.x/eloquent#observers
understood, thanks for the help!
but does the observer has the old and new data? or just the new?
Yes
thanks!!