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
jigsaw4w ago
what about observers?
itsmejyv
itsmejyv4w ago
I'll try it. thanks for recommendation
jigsaw
jigsaw4w ago
have you solved? if so, i'll stop following question
itsmejyv
itsmejyv4w ago
haven't try it
Solution
LeandroFerreira
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