storage = Storage::disk('local'); } public function all() { $searchers = []; $files = $this->storage->files('searchers'); foreach ($files as $file) { if (pathinfo($file, PATHINFO_EXTENSION) === 'json') { $fileName = pathinfo($file, PATHINFO_FILENAME); $result = explode('_', $fileName); if (count($result) < 2) { continue; } $contents = json_decode($this->storage->get($file), true); $description = $contents['description']; $searchers[$fileName] = [ 'id' => $fileName, 'name' => $result[1], 'description' => $description, 'tag' => '', 'param' => SearchersCollection::PARAM_REQUIRED, ]; if (count($result) === 3) { $searchers[$fileName]['tag'] = $result[2]; // $searchers[$fileName]['param'] = SearchersCollection::PARAM_REQUIRED; } // if (count($result) === 3) { // $searchers[$fileName]['param'] = $result[2]; // } } } return $searchers; } public function has($id) { return $this->storage->exists("searchers/$id.json"); } public function get($id) { $contents = $this->storage->get("searchers/$id.json"); return json_decode($contents, true); } public function destroy($id) { if ( ! $this->has($id)) { return false; } return $this->storage->delete("searchers/$id.json"); } }