->afterStateHydrated(function (Group $component, ?Model $record) use ($only): void {
$component->getChildComponentContainer()->fill(
$record?->seo?->only($only) ?: []
);
})
->statePath('seo')
->dehydrated(false)
->saveRelationshipsUsing(function (Model $record, array $state) use ($only): void {
$state = collect($state)->only($only)->map(fn($value) => $value ?: null)->all();
if ($record->seo && $record->seo->exists) {
$record->seo->update($state);
} else {
$record->seo()->create($state);
}
});
->afterStateHydrated(function (Group $component, ?Model $record) use ($only): void {
$component->getChildComponentContainer()->fill(
$record?->seo?->only($only) ?: []
);
})
->statePath('seo')
->dehydrated(false)
->saveRelationshipsUsing(function (Model $record, array $state) use ($only): void {
$state = collect($state)->only($only)->map(fn($value) => $value ?: null)->all();
if ($record->seo && $record->seo->exists) {
$record->seo->update($state);
} else {
$record->seo()->create($state);
}
});