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) { $searchers[$fileName] = [ 'id' => $fileName, 'name' => $result[1], ]; } } } 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"); } }