import_real_data.php 812 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. use App\Services\KnowledgeGraphService;
  3. use Illuminate\Support\Facades\File;
  4. require __DIR__ . '/vendor/autoload.php';
  5. $app = require_once __DIR__ . '/bootstrap/app.php';
  6. $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
  7. $kernel->bootstrap();
  8. $service = app(KnowledgeGraphService::class);
  9. $treePath = public_path('data/tree.json');
  10. $edgesPath = public_path('data/edges.json');
  11. if (!File::exists($treePath) || !File::exists($edgesPath)) {
  12. echo "❌ Data files not found in public/data/\n";
  13. exit(1);
  14. }
  15. $treeData = json_decode(File::get($treePath), true);
  16. $edgesData = json_decode(File::get($edgesPath), true);
  17. echo "Importing real data...\n";
  18. if ($service->importGraph($treeData, $edgesData)) {
  19. echo "✅ Import successful!\n";
  20. } else {
  21. echo "❌ Import failed.\n";
  22. }