How can I dd() content of the relationship

I have fairly simple ProductResource
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),

Forms\Components\Fieldset::make('description')
->relationship('productDescription')
->schema([
TextInput::make('description')
->required(),
TextInput::make('price')
->required(),
])
]);
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),

Forms\Components\Fieldset::make('description')
->relationship('productDescription')
->schema([
TextInput::make('description')
->required(),
TextInput::make('price')
->required(),
])
]);
and I have this in CreateProduct added so I can see what is being passed from form
protected function mutateFormDataBeforeCreate(array $data): array
{
dd($data);
}
protected function mutateFormDataBeforeCreate(array $data): array
{
dd($data);
}
But the problem is that I can only see values of text inputs from first schema, but not second. It all saves to DB but I am curious how to see values from the second ->schema()
2 Replies
LeandroFerreira
LeandroFerreira7mo ago
Add ->dehydrated() after relationship()
Zlatiborac
ZlatiboracOP7mo ago
Can you try and explain to me like I am a complete noob, how can I dd() every value from my ProductResource. So, where to put dd() since the way I am doing it it just dumps 'name' and not description and price. Let's say that I need to check 'price' how can I fetch only that. I am lost here, and can't find the answer anywhere. So after a lot of digging I need to use
mutateRelationshipDataBeforeCreateUsing
mutateRelationshipDataBeforeCreateUsing
to be able to see and manipulate with data that are in relationship. Something like this
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),

Forms\Components\Fieldset::make('description')
->relationship('productDescription')
->schema([
TextInput::make('description')
->required(),
TextInput::make('price')
->required(),
])
->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
dd($data);

return $data;
})
]);
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),

Forms\Components\Fieldset::make('description')
->relationship('productDescription')
->schema([
TextInput::make('description')
->required(),
TextInput::make('price')
->required(),
])
->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
dd($data);

return $data;
})
]);
Why is this so complicated. What if I wanted to manipulate uploaded image that is also in relationship? That would be hell on earth then
Want results from more Discord servers?
Add your server