Certainly! In Filament, when you use a Repeater::make('tenancy_tenants')->relationship(), the data you see in the $data array inside mutateFormDataBeforeSave() does not include the related model data. Instead, it only contains the fields present in the form itself. The relationship data is handled by Filament after the form is saved, using the relationship method you defined.
If you want to inspect the relationship data (for example, the tenants being created/updated), you need to look at the $data['tenancy_tenants'] key, but only if you have defined the fields inside the repeater. If you want to see the actual related models, you need to do this after the model is saved, not in mutateFormDataBeforeSave().
How to Dump Relationship Data
1. Dumping Repeater Data in mutateFormDataBeforeSave()
If you want to see what is being submitted for the repeater, you can do:
public static function mutateFormDataBeforeSave(array $data): array
{
dd($data['tenancy_tenants'] ?? 'No tenants data');
return $data;
}
This will show you the form input for the repeater, not the actual related models.
2. Dumping Actual Related Models After Save
If you want to see the actual related models after saving, you should use the afterSave callback in your resource/page:
public function afterSave()
{
$tenancy = $this->record; // or however you access the saved model
dd($tenancy->tenancy_tenants); // This will show the related models
}
Or, if you are using a Filament Resource Page:
public static function afterSave($record)
{
dd($record->tenancy_tenants); // This will dump the related models
}
3. Storing Relationship Data Separately
If you want to store the repeater data separately, you can do so in mutateFormDataBeforeSave() by extracting it:
public static function mutateFormDataBeforeSave(array $data): array
{
$tenants = $data['tenancy_tenants'] ?? [];
// Store $tenants somewhere, or process as needed
// Optionally remove from $data if you don't want to save via Filament's relationship
// unset($data['tenancy_tenants']);
return $data;
}
Summary
- $data in mutateFormDataBeforeSave() contains only the form input, not the actual related models.
- Relationship data is synced after save by Filament.
- To dump the actual related models, use an
afterSavehook.
Let me know if you need a more specific example for your use case!