Function in aftersave() is not executed

I have this custom function:

CreateTopic('3', $record->titolo, $record->testo, '56')


When I use it as Action it works correctly:


Action::make('Generate Topic')
    ->label('')
    ->icon('far-comments')
    ->action(function (Articoli $record): void {
        $cTopic = CreateTopic('3', $record->titolo, $record->testo, '56');
        $id_topic = json_decode($cTopic->getBody());
    },


For when I use it in CreateArticle.php as afterSave(), it doesn't execute--how come?

    protected function afterSave(): void
    {
        if ($this->record->is_published === 'Published') {
            $cTopic = CreateTopic('3', $this->record->titolo, $this->record->testo, '56');
            $id_topic = json_decode($cTopic->getBody());
        }
    }
Was this page helpful?