F
Filament15mo ago
QCTFW

Access Relationship Input in mutateFormDataBeforeCreate()

Hello, I want to access the relationship inputs in the mutateFormDataBeforeCreate() method, but I can only access the non-relationship inputs. How to do that?
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['cashier_id'] = auth()->id();
return $data;
}
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['cashier_id'] = auth()->id();
return $data;
}
// Data Result
[
"discount" => 10 // from TextInput
"cashier_id" => "01ha16anrawwd9pknhfy3g43yx"
]
// Data Result
[
"discount" => 10 // from TextInput
"cashier_id" => "01ha16anrawwd9pknhfy3g43yx"
]
Solution:
Try dd($this->data), see if the input you want is there
Jump to solution
3 Replies
Solution
Patrick Boivin
Patrick Boivin15mo ago
Try dd($this->data), see if the input you want is there
DariusIII
DariusIII15mo ago
protected function mutateFormDataBeforeCreate(array $data): array { $data['cashier_id'] = auth()->user()->id; return $data; } Maybe like this?
QCTFW
QCTFWOP15mo ago
Sorry for the late response. $this->data does return all the request data. Thank you so much.
Want results from more Discord servers?
Add your server