option('production') || app()->environment('production'); // Only enforce migration mode in development mode without --production flag $require_migration_mode = !$is_production; // Check for migration mode if we require it if ($require_migration_mode) { if (!file_exists($this->flag_file)) { $this->error('❌ Migration mode not active!'); $this->error(''); $this->line('In development mode, you must create a database snapshot before running seeders.'); $this->line('This prevents data corruption if seeding fails.'); $this->info(''); $this->line('To begin a migration session:'); $this->line(' php artisan migrate:begin'); return 1; } $this->info('✅ Migration mode active - snapshot available for rollback'); $this->info(''); } // Call parent handle to run the actual seeding return parent::handle(); } /** * Get a seeder instance from the container * Override to check RSX seeders directory first * * @return \Illuminate\Database\Seeder */ protected function getSeeder() { $class = $this->input->getArgument('class') ?? $this->input->getOption('class'); // If it's a simple class name, try to find it in RSX seeders directory if ($class && !str_contains($class, '\\')) { $seeder_path = \App\RSpade\Core\Database\SeederPaths::get_default_path() . '/' . $class . '.php'; if (file_exists($seeder_path)) { // Load the seeder file directly require_once $seeder_path; // Check if class exists now if (!class_exists($class)) { throw new \RuntimeException("Seeder file found at {$seeder_path} but class {$class} not defined"); } // Create instance directly since it's not in the container $instance = new $class(); return $instance->setContainer($this->laravel)->setCommand($this); } } // Fall back to parent implementation for namespaced seeders return parent::getSeeder(); } }