Finish pack management in Admin CP
This commit is contained in:
parent
4730309589
commit
1c47b2ed55
13 changed files with 352 additions and 455 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue