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
jigsaw4mo ago
what about observers?
itsmejyv
itsmejyvOP4mo ago
I'll try it. thanks for recommendation
jigsaw
jigsaw4mo ago
have you solved? if so, i'll stop following question
itsmejyv
itsmejyvOP4mo ago
haven't try it
Solution
LeandroFerreira
LeandroFerreira4mo 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);
}
Want results from more Discord servers?
Add your server