public function getFullList(Request $request) { // $context = $this->isWCF($request) ? 'xml' : 'html'; $context = 'xml'; // Force XML for now $packages = Package::all(); $content = $this->getCachedContent('xml.renderedPath', function () use($context, $packages) { return view($context . '.list')->with('packages', $packages); }); return $this->response($context, $content); }
public function getPackageWithVersion($identifier, $versionNumber) { $package = Package::withIdentifier($identifier); if (!$package) { abort(404); } $version = null; foreach ($package->versions as $v) { if ($v->isVersion($versionNumber)) { $version = $v; break; } } if (!$version) { abort(404); } if (!file_exists($version->storagePath)) { abort(404); } return response()->download($version->storagePath, $identifier . '.tar'); }
/** * Retrieves the stored package with the given identifier or creates a new one. * * @param string $identifier The identifier for the package to be retrieved * @return Package */ protected function buildPackage() { $package = Package::withIdentifier($this->identifier); if (!$package) { $package = new Package(['identifier' => $this->identifier]); } return $package; }