| Conditions | 4 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 40 | public function handle() |
||
| 41 | { |
||
| 42 | $elasticSearch = ElasticSearchBuilder::create()->setHosts(config('elasticsearch.hosts'))->build()->indices(); |
||
|
|
|||
| 43 | |||
| 44 | $index = config('elasticsearch.index'); |
||
| 45 | if ($elasticSearch->exists(['index' => $index])) { |
||
| 46 | $this->error(sprintf('The "%s" index already exists', $index)); |
||
| 47 | return; |
||
| 48 | } |
||
| 49 | $params = config('elasticsearch.' . $index); |
||
| 50 | |||
| 51 | if (!empty($params)) { |
||
| 52 | try { |
||
| 53 | $elasticSearch->create($params); |
||
| 54 | } catch (Exception $e) { |
||
| 55 | $this->error($e->getMessage()); |
||
| 56 | return; |
||
| 57 | } |
||
| 58 | $this->info(sprintf('"%s" index created successfully', $index)); |
||
| 59 | return; |
||
| 60 | } else { |
||
| 61 | $this->warn(sprintf('"%s" index configuration not found', $index)); |
||
| 62 | return; |
||
| 63 | } |
||
| 66 |