More fixes
This commit is contained in:
parent
17642bffe7
commit
c19c423568
14 changed files with 67 additions and 61 deletions
|
@ -114,7 +114,7 @@ class PackController extends Controller
|
|||
public function index(Request $request)
|
||||
{
|
||||
return view('admin.packs.index', [
|
||||
'packs' => $this->repository->search($request->input('query'))->paginateWithOptionAndServerCount(
|
||||
'packs' => $this->repository->search($request->input('query'))->paginateWithEggAndServerCount(
|
||||
$this->config->get('pterodactyl.paginate.admin.packs')
|
||||
),
|
||||
]);
|
||||
|
@ -124,11 +124,13 @@ class PackController extends Controller
|
|||
* Display new pack creation form.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('admin.packs.new', [
|
||||
'services' => $this->serviceRepository->getWithOptions(),
|
||||
'nests' => $this->serviceRepository->getWithEggs(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -136,11 +138,13 @@ class PackController extends Controller
|
|||
* Display new pack creation modal for use with template upload.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function newTemplate()
|
||||
{
|
||||
return view('admin.packs.modal', [
|
||||
'services' => $this->serviceRepository->getWithOptions(),
|
||||
'nests' => $this->serviceRepository->getWithEggs(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -160,7 +164,7 @@ class PackController extends Controller
|
|||
public function store(PackFormRequest $request)
|
||||
{
|
||||
if ($request->has('from_template')) {
|
||||
$pack = $this->templateUploadService->handle($request->input('option_id'), $request->file('file_upload'));
|
||||
$pack = $this->templateUploadService->handle($request->input('egg_id'), $request->file('file_upload'));
|
||||
} else {
|
||||
$pack = $this->creationService->handle($request->normalize(), $request->file('file_upload'));
|
||||
}
|
||||
|
@ -175,12 +179,13 @@ class PackController extends Controller
|
|||
*
|
||||
* @param int $pack
|
||||
* @return \Illuminate\View\View
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function view($pack)
|
||||
{
|
||||
return view('admin.packs.view', [
|
||||
'pack' => $this->repository->getWithServers($pack),
|
||||
'services' => $this->serviceRepository->getWithOptions(),
|
||||
'nests' => $this->serviceRepository->getWithEggs(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class ServerFormRequest extends AdminFormRequest
|
|||
$validator->sometimes('pack_id', [
|
||||
Rule::exists('packs', 'id')->where(function ($query) {
|
||||
$query->where('selectable', 1);
|
||||
$query->where('option_id', $this->input('option_id'));
|
||||
$query->where('egg_id', $this->input('egg_id'));
|
||||
}),
|
||||
], function ($input) {
|
||||
return $input->pack_id !== 0 && $input->pack_id !== null;
|
||||
|
|
|
@ -34,7 +34,7 @@ class Pack extends Model implements CleansAttributes, ValidableContract
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'option_id', 'uuid', 'name', 'version', 'description', 'selectable', 'visible', 'locked',
|
||||
'egg_id', 'uuid', 'name', 'version', 'description', 'selectable', 'visible', 'locked',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,10 +54,10 @@ class PackUpdateService
|
|||
public function handle($pack, array $data)
|
||||
{
|
||||
if (! $pack instanceof Pack) {
|
||||
$pack = $this->repository->withColumns(['id', 'option_id'])->find($pack);
|
||||
$pack = $this->repository->withColumns(['id', 'egg_id'])->find($pack);
|
||||
}
|
||||
|
||||
if ((int) array_get($data, 'option_id', $pack->option_id) !== $pack->option_id) {
|
||||
if ((int) array_get($data, 'egg_id', $pack->egg_id) !== $pack->egg_id) {
|
||||
$count = $this->serverRepository->findCountWhere([['pack_id', '=', $pack->id]]);
|
||||
|
||||
if ($count !== 0) {
|
||||
|
|
|
@ -52,7 +52,7 @@ class TemplateUploadService
|
|||
/**
|
||||
* Process an uploaded file to create a new pack from a JSON or ZIP format.
|
||||
*
|
||||
* @param int $option
|
||||
* @param int $egg
|
||||
* @param \Illuminate\Http\UploadedFile $file
|
||||
* @return \Pterodactyl\Models\Pack
|
||||
*
|
||||
|
@ -63,7 +63,7 @@ class TemplateUploadService
|
|||
* @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException
|
||||
*/
|
||||
public function handle($option, UploadedFile $file)
|
||||
public function handle($egg, UploadedFile $file)
|
||||
{
|
||||
if (! $file->isValid()) {
|
||||
throw new InvalidFileUploadException(trans('exceptions.packs.invalid_upload'));
|
||||
|
@ -76,10 +76,10 @@ class TemplateUploadService
|
|||
}
|
||||
|
||||
if ($file->getMimeType() === 'application/zip') {
|
||||
return $this->handleArchive($option, $file);
|
||||
return $this->handleArchive($egg, $file);
|
||||
} else {
|
||||
$json = json_decode($file->openFile()->fread($file->getSize()), true);
|
||||
$json['option_id'] = $option;
|
||||
$json['egg_id'] = $egg;
|
||||
|
||||
return $this->creationService->handle($json);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class TemplateUploadService
|
|||
/**
|
||||
* Process a ZIP file to create a pack and stored archive.
|
||||
*
|
||||
* @param int $option
|
||||
* @param int $egg
|
||||
* @param \Illuminate\Http\UploadedFile $file
|
||||
* @return \Pterodactyl\Models\Pack
|
||||
*
|
||||
|
@ -99,7 +99,7 @@ class TemplateUploadService
|
|||
* @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException
|
||||
*/
|
||||
protected function handleArchive($option, $file)
|
||||
protected function handleArchive($egg, $file)
|
||||
{
|
||||
if (! $this->archive->open($file->getRealPath())) {
|
||||
throw new UnreadableZipArchiveException(trans('exceptions.packs.unreadable'));
|
||||
|
@ -110,7 +110,7 @@ class TemplateUploadService
|
|||
}
|
||||
|
||||
$json = json_decode($this->archive->getFromName('import.json'), true);
|
||||
$json['option_id'] = $option;
|
||||
$json['egg_id'] = $egg;
|
||||
|
||||
$pack = $this->creationService->handle($json);
|
||||
if (! $this->archive->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) {
|
||||
|
|
|
@ -124,7 +124,7 @@ class ServerCreationService
|
|||
public function create(array $data)
|
||||
{
|
||||
// @todo auto-deployment
|
||||
$validator = $this->validatorService->isAdmin()->setFields($data['environment'])->validate($data['option_id']);
|
||||
$validator = $this->validatorService->isAdmin()->setFields($data['environment'])->validate($data['egg_id']);
|
||||
$uniqueShort = str_random(8);
|
||||
|
||||
$this->connection->beginTransaction();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue