Ejemplo n.º 1
0
 /**
  * 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.');
     }
 }
Ejemplo n.º 2
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.');
     }
 }
Ejemplo n.º 3
0
 /**
  * Execute the query and return the response in a rich wrapper class
  *
  * @return Response
  */
 public function execute()
 {
     $this->getFields();
     $this->getPagination();
     $this->getHighlight();
     $this->getSuggest();
     $this->getAggregations();
     $this->getPayload();
     $params = ['index' => Utils::findKey($this->options, 'index', false) ?: $this->proxy->getIndex()->getName(), 'type' => Utils::findKey($this->options, 'type', false) ?: $this->proxy->getType(), 'body' => $this->payload];
     return new Response($this->proxy->getModel(), $this->proxy->getClient()->search($params));
 }