Access relationship data in mutateFormDataBeforeCreate
I have created a Repeater that goes into another model 'invoice_rows' like this:
Forms\Components\Repeater::make('invoice_rows')->label('Factuur regels')->relationship('row')
with the ->relationship('row')
function.
But in my resource Create file (CreateAdminInvoices.php) I use protected function mutateFormDataBeforeCreate(array $data)
and I want to access the form data of the relationship there as well, but that's not included in the $data variable. How do I make that accessible there as well?4 Replies
Now I found a way of accessing the data if I do
dd($this->data)
I can see the full form data, is that a valid way?Yeah that's fine. It's not included in the state, as it saves directly to the DB. There is also a
mutateRelationshipDataBeforeCreate
(or similar naming)@boomstam
i would advise against reading the data directly from the form
the method that dennis suggests is the safest way
Thanks, I will implement that!