Finish pack management in Admin CP

This commit is contained in:
Dane Everitt 2017-03-15 20:52:37 -04:00
parent 4730309589
commit 1c47b2ed55
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
13 changed files with 352 additions and 455 deletions

View file

@ -24,6 +24,8 @@
namespace Pterodactyl\Models;
use File;
use Storage;
use Illuminate\Database\Eloquent\Model;
use Nicolaslopezj\Searchable\SearchableTrait;
@ -78,6 +80,29 @@ class Pack extends Model
],
];
/**
* Returns all of the archived files for a given pack.
*
* @param bool $collection
* @return \Illuminate\Support\Collection|object
*/
public function files($collection = false)
{
$files = collect(Storage::files('packs/' . $this->uuid));
$files = $files->map(function ($item) {
$path = storage_path('app/' . $item);
return (object) [
'name' => basename($item),
'hash' => sha1_file($path),
'size' => File::humanReadableSize($path),
];
});
return ($collection) ? $files : (object) $files->all();
}
/**
* Gets option associated with a service pack.
*