Example #1
0
 /**
  * Scan directories for Eloquent models that use the SearchableTrait.
  * Generate paths for all these models so that we can (re)index these
  * models.
  *
  * @return void
  */
 public function fire()
 {
     $models = $this->argument('model');
     foreach ($models as $model) {
         $this->compilePaths(new $model());
     }
     if ($directories = $this->option('dir')) {
         $directoryModels = array_diff(Utils::findSearchableModels($directories), $models);
         foreach ($directoryModels as $model) {
             // Find paths for related models
             $this->compilePaths(new $model());
         }
     }
     if (!empty($models) || !empty($directoryModels)) {
         $this->writeConfig();
     } else {
         $this->info('No models found.');
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $directoryModels = [];
     $models = $this->argument('model');
     foreach ($models as $model) {
         $instance = $this->getModelInstance($model);
         $this->reindexModel($instance);
     }
     if ($directories = $this->option('dir')) {
         $directoryModels = array_diff(Utils::findSearchableModels($directories), $models);
         foreach ($directoryModels as $model) {
             $instance = $this->getModelInstance($model);
             $this->reindexModel($instance);
         }
     }
     if (empty($models) && empty($directoryModels)) {
         $this->info('No models found.');
     }
 }