update related model value
any way to update the orders status to paid when selecting the payment as paid ? thanks
3 Replies
yea something like after method
it works but it puts in wrong values
php
but the values are random for order->status idk why
like if i set it to paid order will be pending , or if i set to declied will be paid etc
The
after()
method of the Select form classes is related to validation. You need to use the afterSave()
and afterCreate()
methods in the pages. In my opinion, this context is better suited for a model observer. If you cast the attributes correctly in the models and use the Filament methods in your enum, you can avoid using ->value
in most places. To access the model in the lifecycle hooks, you can use $this->record
https://filamentphp.com/docs/3.x/panels/resources/editing-records#lifecycle-hooks
https://filamentphp.com/docs/3.x/panels/resources/creating-records#lifecycle-hooks