Add initial pack creation and overview pages

This commit is contained in:
Dane Everitt 2017-03-14 21:18:36 -04:00
parent 2d90187c83
commit 50558db7c3
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
21 changed files with 944 additions and 487 deletions

View file

@ -27,179 +27,124 @@ namespace Pterodactyl\Http\Controllers\Admin;
use Log;
use Alert;
use Storage;
use Pterodactyl\Models;
use Illuminate\Http\Request;
use Pterodactyl\Models\Pack;
use Pterodactyl\Models\Service;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\ServiceRepository\Pack;
use Pterodactyl\Repositories\PackRepository;
use Pterodactyl\Exceptions\DisplayValidationException;
class PackController extends Controller
{
public function __construct()
/**
* Display listing of all packs on the system.
*
* @param Request $request
* @return \Illuminate\View\View
*/
public function index(Request $request)
{
//
$packs = Pack::with('option')->withCount('servers');
if (! is_null($request->input('query'))) {
$packs->search($request->input('query'));
}
return view('admin.packs.index', ['packs' => $packs->paginate(50)]);
}
public function listAll(Request $request)
/**
* Display new pack creation form.
*
* @param Request $request
* @return \Illuminate\View\View
*/
public function new(Request $request)
{
return view('admin.services.packs.index', ['services' => Models\Service::all()]);
}
public function listByOption(Request $request, $id)
{
return view('admin.services.packs.byoption', [
'option' => Models\ServiceOption::with('service', 'packs')->findOrFail($id),
return view('admin.packs.new', [
'services' => Service::with('options')->get(),
]);
}
public function listByService(Request $request, $id)
/**
* Display new pack creation modal for use with template upload.
*
* @param Request $request
* @return \Illuminate\View\View
*/
public function newTemplate(Request $request)
{
return view('admin.services.packs.byservice', [
'service' => Models\Service::with('options', 'options.packs')->findOrFail($id),
]);
}
public function new(Request $request, $opt = null)
{
return view('admin.services.packs.new', [
'services' => Models\Service::with('options')->get(),
return view('admin.packs.modal', [
'services' => Service::with('options')->get(),
]);
}
public function create(Request $request)
{
$repo = new PackRepository;
try {
$repo = new Pack;
$pack = $repo->create($request->only([
'name', 'version', 'description',
'option', 'selectable', 'visible',
'file_upload',
]));
Alert::success('Successfully created new service!')->flash();
return redirect()->route('admin.services.packs.edit', $pack->id)->withInput();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.packs.new', $request->input('option'))->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to add a new service pack.')->flash();
}
return redirect()->route('admin.services.packs.new', $request->input('option'))->withInput();
}
public function edit(Request $request, $id)
{
$pack = Models\ServicePack::with('option.service')->findOrFail($id);
return view('admin.services.packs.edit', [
'pack' => $pack,
'services' => Models\Service::all()->load('options'),
'files' => Storage::files('packs/' . $pack->uuid),
]);
}
public function update(Request $request, $id)
{
if (! is_null($request->input('action_delete'))) {
try {
$repo = new Pack;
$repo->delete($id);
Alert::success('The requested service pack has been deleted from the system.')->flash();
return redirect()->route('admin.services.packs');
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to delete this pack.')->flash();
}
return redirect()->route('admin.services.packs.edit', $id);
} else {
try {
$repo = new Pack;
$repo->update($id, $request->only([
'name', 'version', 'description',
'option', 'selectable', 'visible',
if ($request->input('action') === 'from_template') {
$pack = $repo->createWithTemplate($request->intersect(['option_id', 'file_upload']));
} else {
$pack = $repo->create($request->intersect([
'name', 'description', 'version', 'option_id',
'selectable', 'visible', 'locked', 'file_upload',
]));
Alert::success('Service pack has been successfully updated.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.packs.edit', $id)->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to add edit this pack.')->flash();
}
Alert::success('Pack successfully created on the system.')->flash();
return redirect()->route('admin.services.packs.edit', $id);
}
}
public function export(Request $request, $id, $files = false)
{
$pack = Models\ServicePack::findOrFail($id);
$json = [
'name' => $pack->name,
'version' => $pack->version,
'description' => $pack->dscription,
'selectable' => (bool) $pack->selectable,
'visible' => (bool) $pack->visible,
];
$filename = tempnam(sys_get_temp_dir(), 'pterodactyl_');
if ((bool) $files) {
$zip = new \ZipArchive;
if (! $zip->open($filename, \ZipArchive::CREATE)) {
abort(503, 'Unable to open file for writing.');
}
$files = Storage::files('packs/' . $pack->uuid);
foreach ($files as $file) {
$zip->addFile(storage_path('app/' . $file), basename(storage_path('app/' . $file)));
}
$zip->addFromString('import.json', json_encode($json, JSON_PRETTY_PRINT));
$zip->close();
return response()->download($filename, 'pack-' . $pack->name . '.zip')->deleteFileAfterSend(true);
} else {
$fp = fopen($filename, 'a+');
fwrite($fp, json_encode($json, JSON_PRETTY_PRINT));
fclose($fp);
return response()->download($filename, 'pack-' . $pack->name . '.json', [
'Content-Type' => 'application/json',
])->deleteFileAfterSend(true);
}
}
public function uploadForm(Request $request, $for = null)
{
return view('admin.services.packs.upload', [
'services' => Models\Service::all()->load('options'),
]);
}
public function postUpload(Request $request)
{
try {
$repo = new Pack;
$pack = $repo->createWithTemplate($request->only(['option', 'file_upload']));
Alert::success('Successfully created new service!')->flash();
return redirect()->route('admin.services.packs.edit', $pack->id)->withInput();
} catch (DisplayValidationException $ex) {
return redirect()->back()->withErrors(json_decode($ex->getMessage()))->withInput();
return redirect()->route('admin.packs.view', $pack->id);
} catch(DisplayValidationException $ex) {
return redirect()->route('admin.packs.new')->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to add a new service pack.')->flash();
Alert::danger('An error occured while attempting to add a new service pack. This error has been logged.')->flash();
}
return redirect()->back();
return redirect()->route('admin.packs.new')->withInput();
}
// public function export(Request $request, $id, $files = false)
// {
// $pack = Models\Pack::findOrFail($id);
// $json = [
// 'name' => $pack->name,
// 'version' => $pack->version,
// 'description' => $pack->dscription,
// 'selectable' => (bool) $pack->selectable,
// 'visible' => (bool) $pack->visible,
// ];
// $filename = tempnam(sys_get_temp_dir(), 'pterodactyl_');
// if ((bool) $files) {
// $zip = new \ZipArchive;
// if (! $zip->open($filename, \ZipArchive::CREATE)) {
// abort(503, 'Unable to open file for writing.');
// }
// $files = Storage::files('packs/' . $pack->uuid);
// foreach ($files as $file) {
// $zip->addFile(storage_path('app/' . $file), basename(storage_path('app/' . $file)));
// }
// $zip->addFromString('import.json', json_encode($json, JSON_PRETTY_PRINT));
// $zip->close();
// return response()->download($filename, 'pack-' . $pack->name . '.zip')->deleteFileAfterSend(true);
// } else {
// $fp = fopen($filename, 'a+');
// fwrite($fp, json_encode($json, JSON_PRETTY_PRINT));
// fclose($fp);
// return response()->download($filename, 'pack-' . $pack->name . '.json', [
// 'Content-Type' => 'application/json',
// ])->deleteFileAfterSend(true);
// }
// }
}

View file

@ -47,7 +47,7 @@ class PackController extends Controller
*/
public function pull(Request $request, $uuid)
{
$pack = Models\ServicePack::where('uuid', $uuid)->first();
$pack = Models\Pack::where('uuid', $uuid)->first();
if (! $pack) {
return response()->json(['error' => 'No such pack.'], 404);
@ -68,7 +68,7 @@ class PackController extends Controller
*/
public function hash(Request $request, $uuid)
{
$pack = Models\ServicePack::where('uuid', $uuid)->first();
$pack = Models\Pack::where('uuid', $uuid)->first();
if (! $pack) {
return response()->json(['error' => 'No such pack.'], 404);

View file

@ -453,43 +453,27 @@ class AdminRoutes
'csrf',
],
], function () use ($router) {
// $router->get('/new/{option?}', [
// 'as' => 'admin.packs.new',
// 'uses' => 'Admin\PackController@new',
// ]);
// $router->post('/new', [
// 'uses' => 'Admin\PackController@create',
// ]);
// $router->get('/upload/{option?}', [
// 'as' => 'admin.packs.uploadForm',
// 'uses' => 'Admin\PackController@uploadForm',
// ]);
// $router->post('/upload', [
// 'uses' => 'Admin\PackController@postUpload',
// ]);
$router->get('/', [
'as' => 'admin.packs',
'uses' => 'Admin\PackController@listAll',
'uses' => 'Admin\PackController@index',
]);
$router->get('/new', [
'as' => 'admin.packs.new',
'uses' => 'Admin\PackController@new',
]);
$router->post('/new', 'Admin\PackController@create');
$router->get('/new/template', [
'as' => 'admin.packs.new.template',
'uses' => 'Admin\PackController@newTemplate',
]);
$router->get('/view/{id}', [
'as' => 'admin.packs.view',
'uses' => 'Admin\PackController@view',
]);
// $router->get('/for/option/{option}', [
// 'as' => 'admin.packs.option',
// 'uses' => 'Admin\PackController@listByOption',
// ]);
// $router->get('/for/service/{service}', [
// 'as' => 'admin.packs.service',
// 'uses' => 'Admin\PackController@listByService',
// ]);
// $router->get('/edit/{pack}', [
// 'as' => 'admin.packs.edit',
// 'uses' => 'Admin\PackController@edit',
// ]);
// $router->post('/edit/{pack}', [
// 'uses' => 'Admin\PackController@update',
// ]);
// $router->get('/edit/{pack}/export/{archive?}', [
// 'as' => 'admin.packs.export',
// 'uses' => 'Admin\PackController@export',
// ]);
});
}
}

100
app/Models/Pack.php Normal file
View file

@ -0,0 +1,100 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Model;
use Nicolaslopezj\Searchable\SearchableTrait;
class Pack extends Model
{
use SearchableTrait;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'packs';
/**
* Fields that are mass assignable.
*
* @var array
*/
protected $fillable = [
'option_id', 'name', 'version', 'description', 'selectable', 'visible', 'locked',
];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'option_id' => 'integer',
'selectable' => 'boolean',
'visible' => 'boolean',
'locked' => 'boolean',
];
/**
* Parameters for search querying.
*
* @var array
*/
protected $searchable = [
'columns' => [
'packs.name' => 10,
'packs.uuid' => 8,
'service_options.name' => 6,
'service_options.tag' => 5,
'service_options.docker_image' => 5,
'packs.version' => 2,
],
'joins' => [
'service_options' => ['packs.option_id', 'service_options.id'],
],
];
/**
* Gets option associated with a service pack.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function option()
{
return $this->belongsTo(ServiceOption::class);
}
/**
* Gets servers associated with a pack.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function servers()
{
return $this->hasMany(Server::class);
}
}

View file

@ -65,43 +65,50 @@ class Server extends Model
*/
protected $guarded = ['id', 'installed', 'created_at', 'updated_at', 'deleted_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'node_id' => 'integer',
'suspended' => 'integer',
'owner_id' => 'integer',
'memory' => 'integer',
'swap' => 'integer',
'disk' => 'integer',
'io' => 'integer',
'cpu' => 'integer',
'oom_disabled' => 'integer',
'allocation_id' => 'integer',
'service_id' => 'integer',
'option_id' => 'integer',
'pack_id' => 'integer',
'installed' => 'integer',
];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'node_id' => 'integer',
'suspended' => 'integer',
'owner_id' => 'integer',
'memory' => 'integer',
'swap' => 'integer',
'disk' => 'integer',
'io' => 'integer',
'cpu' => 'integer',
'oom_disabled' => 'integer',
'allocation_id' => 'integer',
'service_id' => 'integer',
'option_id' => 'integer',
'pack_id' => 'integer',
'installed' => 'integer',
];
/**
* Parameters for search querying.
*
* @var array
*/
protected $searchable = [
'columns' => [
'servers.name' => 10,
'servers.username' => 10,
'servers.uuidShort' => 9,
'servers.uuid' => 8,
'users.email' => 6,
'users.username' => 6,
'nodes.name' => 2,
],
'joins' => [
'columns' => [
'servers.name' => 10,
'servers.username' => 10,
'servers.uuidShort' => 9,
'servers.uuid' => 8,
'packs.name' => 7,
'users.email' => 6,
'users.username' => 6,
'nodes.name' => 2,
],
'joins' => [
'packs' => ['packs.id', 'servers.pack_id'],
'users' => ['users.id', 'servers.owner_id'],
'nodes' => ['nodes.id', 'servers.node_id'],
],
];
],
];
/**
* Returns a single server specified by UUID.
@ -236,11 +243,11 @@ class Server extends Model
/**
* Gets information for the pack associated with this server.
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function pack()
{
return $this->hasOne(ServicePack::class, 'id', 'pack_id');
return $this->belongsTo(Pack::class);
}
/**

View file

@ -105,7 +105,7 @@ EOF;
public function packs()
{
return $this->hasManyThrough(
'Pterodactyl\Models\ServicePack', 'Pterodactyl\Models\ServiceOption',
'Pterodactyl\Models\Pack', 'Pterodactyl\Models\ServiceOption',
'service_id', 'option_id'
);
}

View file

@ -99,6 +99,6 @@ class ServiceOption extends Model
*/
public function packs()
{
return $this->hasMany(ServicePack::class, 'option_id');
return $this->hasMany(Pack::class, 'option_id');
}
}

View file

@ -1,69 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Model;
class ServicePack extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'service_packs';
/**
* Fields that are not mass assignable.
*
* @var array
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'option' => 'integer',
'build_memory' => 'integer',
'build_swap' => 'integer',
'build_cpu' => 'integer',
'build_io' => 'integer',
'selectable' => 'boolean',
'visible' => 'boolean',
];
/**
* Gets option associated with a service pack.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function option()
{
return $this->belongsTo(ServiceOption::class);
}
}

View file

@ -88,6 +88,11 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
*/
protected $hidden = ['password', 'remember_token', 'totp_secret'];
/**
* Parameters for search querying.
*
* @var array
*/
protected $searchable = [
'columns' => [
'email' => 10,

View file

@ -28,31 +28,36 @@ use DB;
use Uuid;
use Storage;
use Validator;
use Pterodactyl\Models;
use Pterodactyl\Models\Pack;
use Pterodactyl\Services\UuidService;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Exceptions\DisplayValidationException;
class PackRepository
{
public function __construct()
{
//
}
/**
* Creates a new pack on the system.
*
* @param array $data
* @return \Pterodactyl\Models\Pack
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create(array $data)
{
$validator = Validator::make($data, [
'name' => 'required|string',
'version' => 'required|string',
'description' => 'sometimes|nullable|string',
'option' => 'required|exists:service_options,id',
'selectable' => 'sometimes|boolean',
'visible' => 'sometimes|boolean',
'selectable' => 'sometimes|required|boolean',
'visible' => 'sometimes|required|boolean',
'locked' => 'sometimes|required|boolean',
'option_id' => 'required|exists:service_options,id',
]);
if ($validator->fails()) {
throw new DisplayValidationException($validator->errors());
throw new DisplayValidationException(json_encode($validator->errors()));
}
if (isset($data['file_upload'])) {
@ -65,33 +70,42 @@ class PackRepository
}
}
DB::beginTransaction();
try {
$uuid = new UuidService;
$pack = Models\ServicePack::create([
'option_id' => $data['option'],
'uuid' => $uuid->generate('service_packs', 'uuid'),
return DB::transaction(function () use ($data) {
$uuid = new UuidService();
$pack = new Pack;
$pack->uuid = $uuid->generate('packs', 'uuid');
$pack->fill([
'option_id' => $data['option_id'],
'name' => $data['name'],
'version' => $data['version'],
'description' => (empty($data['description'])) ? null : $data['description'],
'selectable' => isset($data['selectable']),
'visible' => isset($data['visible']),
]);
'locked' => isset($data['locked']),
])->save();
if (! $pack->exists) {
throw new DisplayException('Model does not exist after creation. Did an event prevent it from saving?');
}
Storage::makeDirectory('packs/' . $pack->uuid);
if (isset($data['file_upload'])) {
$data['file_upload']->storeAs('packs/' . $pack->uuid, 'archive.tar.gz');
}
DB::commit();
} catch (\Exception $ex) {
DB::rollBack();
throw $ex;
}
return $pack;
return $pack;
});
}
/**
* Creates a new pack on the system given a template file.
*
* @param array $data
* @return \Pterodactyl\Models\Pack
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function createWithTemplate(array $data)
{
if (! isset($data['file_upload'])) {
@ -127,9 +141,10 @@ class PackRepository
'name' => $json->name,
'version' => $json->version,
'description' => $json->description,
'option' => $data['option'],
'option_id' => $data['option_id'],
'selectable' => $json->selectable,
'visible' => $json->visible,
'locked' => $json->locked,
]);
if (! $zip->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) {
@ -147,42 +162,67 @@ class PackRepository
'name' => $json->name,
'version' => $json->version,
'description' => $json->description,
'option' => $data['option'],
'option_id' => $data['option_id'],
'selectable' => $json->selectable,
'visible' => $json->visible,
'locked' => $json->locked,
]);
}
}
/**
* Updates a pack on the system.
*
* @param int $id
* @param array $data
* @return \Pterodactyl\Models\Pack
*
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function update($id, array $data)
{
$validator = Validator::make($data, [
'name' => 'required|string',
'version' => 'required|string',
'description' => 'string',
'option' => 'required|exists:service_options,id',
'selectable' => 'sometimes|boolean',
'visible' => 'sometimes|boolean',
'name' => 'sometimes|required|string',
'version' => 'sometimes|required|string',
'description' => 'sometimes|string',
'selectable' => 'sometimes|required|boolean',
'visible' => 'sometimes|required|boolean',
'locked' => 'sometimes|required|boolean',
]);
if ($validator->fails()) {
throw new DisplayValidationException($validator->errors());
throw new DisplayValidationException(json_encode($validator->errors()));
}
Models\ServicePack::findOrFail($id)->update([
'option_id' => $data['option'],
'name' => $data['name'],
'version' => $data['version'],
$pack = Pack::findOrFail($id);
$pack->fill([
'name' => isset($data['name']) ? $data['name'] : $pack->name,
'version' => isset($data['version']) ? $data['version'] : $pack->version,
'description' => (empty($data['description'])) ? null : $data['description'],
'selectable' => isset($data['selectable']),
'visible' => isset($data['visible']),
]);
'selectable' => isset($data['selectable']) ? $data['selectable'] : $data->selectable,
'visible' => isset($data['visible']) ? $data['visible'] : $data->visible,
'locked' => isset($data['locked']) ? $data['locked'] : $data->locked,
])->save();
return $pack;
}
/**
* Deletes a pack and files from the system.
*
* @param int $id
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete($id)
{
$pack = Models\ServicePack::findOrFail($id);
// @TODO Check for linked servers; foreign key should block this.
$pack = Models\Pack::withCount('servers')->findOrFail($id);
if ($pack->servers_count > 0) {
throw new DisplayException('Cannot delete a pack from the system if servers are assocaited with it.');
}
DB::transaction(function () use ($pack) {
$pack->delete();
Storage::deleteDirectory('packs/' . $pack->uuid);

View file

@ -156,7 +156,7 @@ class ServerRepository
if (! isset($data['pack_id']) || (int) $data['pack_id'] < 1) {
$data['pack_id'] = null;
} else {
$pack = Models\ServicePack::where('id', $data['pack_id'])->where('option_id', $data['option_id'])->first();
$pack = Models\Pack::where('id', $data['pack_id'])->where('option_id', $data['option_id'])->first();
if (! $pack) {
throw new DisplayException('The requested service pack does not seem to exist for this combination.');
}