argument('model'); $modelId = $this->option('id'); // Build full model class name $modelClass = "App\\Models\\{$modelName}"; if (!class_exists($modelClass)) { $this->error("Model {$modelClass} does not exist."); return 1; } try { if ($modelId) { // Reindex specific model $model = $modelClass::find($modelId); if (!$model) { $this->error("Model {$modelName} with ID {$modelId} not found."); return 1; } $this->info("Reindexing {$modelName} #{$modelId}..."); // Force reindex the model $model->searchable(); $this->info("✅ Successfully reindexed {$modelName} #{$modelId}"); } else { $this->error("Please specify --id=X"); return 1; } } catch (\Exception $e) { $this->error("Failed to reindex: " . $e->getMessage()); return 1; } return 0; } }