Is it possible to insert or create a copy of data automatically from current table to other table?

Is is possible, when I create a data in tb1 it will create also a copy in tb2? I'm trying an automation here, I'm trying to insert the data from current form to othe table upon submission.
Solution:
observers or afterCreate hook in your CreatePage ```php protected function afterCreate(): void {...
Jump to solution
5 Replies
jigsaw
jigsaw6mo ago
what about observers?
itsmejyv
itsmejyvOP5mo ago
I'll try it. thanks for recommendation
jigsaw
jigsaw5mo ago
have you solved? if so, i'll stop following question
itsmejyv
itsmejyvOP5mo ago
haven't try it
Solution
LeandroFerreira
LeandroFerreira5mo ago
observers or afterCreate hook in your CreatePage
protected function afterCreate(): void
{
$replicate = $this->record->replicate();
$replicate = $replicate->toArray();

AnotherModel::firstOrCreate($replicate);
}
protected function afterCreate(): void
{
$replicate = $this->record->replicate();
$replicate = $replicate->toArray();

AnotherModel::firstOrCreate($replicate);
}

Did you find this page helpful?