Ejemplo n.º 1
0
 /**
  * Handle the command.
  *
  * @param Application $application
  */
 public function handle(Application $application, Filesystem $files)
 {
     if (!class_exists('TeamTNT\\TNTSearch\\TNTSearch')) {
         return;
     }
     if (!class_exists($this->stream->getEntryModelName())) {
         return;
     }
     $model = $this->stream->getEntryModel();
     $index = $application->getStoragePath('search/' . $model->searchableAs() . '.index');
     if ($this->stream->isSearchable() && file_exists($index)) {
         return;
     }
     if (!$this->stream->isSearchable() && file_exists($index)) {
         $files->delete($index);
         return;
     }
     if (!$this->stream->isSearchable()) {
         return;
     }
     try {
         app(EngineManager::class)->engine('tntsearch')->initIndex($model);
     } catch (\Exception $e) {
         // Kewl.
     }
 }
 /**
  * Return the use statement for trashable if so.
  *
  * @param  StreamInterface $stream
  * @return string
  */
 public function parse(StreamInterface $stream)
 {
     if (!$stream->isSearchable()) {
         return "false";
     }
     return "true";
 }