Dispatch event in lifecycle hook

Hello, I want to dispatch an event in the lifecycle hook after creating a resource
class CreateMyResource extends CreateRecord
{
    protected static string $resource = MyResource::class;
   
 public function afterCreate(): void
    {
      ...
        Event::dispatch(new CreateADatabase($model['id'], $projectId, $branchId, $roleId, $databaseName));
    }
}

My event is not firing. Is there any other way of firing the event? Thank you.
Was this page helpful?