Completed model updates for Services

This commit is contained in:
Dane Everitt 2017-02-05 17:58:17 -05:00
parent 09d23deed6
commit 323f1d943f
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
26 changed files with 299 additions and 167 deletions

View file

@ -53,7 +53,7 @@ class ServiceController extends BaseController
return [
'service' => $service,
'options' => Models\ServiceOptions::select('id', 'name', 'description', 'tag', 'docker_image')
->where('parent_service', $service->id)
->where('service_id', $service->id)
->with('variables')
->with('packs')
->get(),

View file

@ -42,64 +42,29 @@ class PackController extends Controller
//
}
protected function formatServices()
{
$options = Models\ServiceOptions::select(
'services.name AS p_service',
'service_options.id',
'service_options.name'
)->join('services', 'services.id', '=', 'service_options.parent_service')->get();
$array = [];
foreach ($options as &$option) {
if (! array_key_exists($option->p_service, $array)) {
$array[$option->p_service] = [];
}
$array[$option->p_service] = array_merge($array[$option->p_service], [[
'id' => $option->id,
'name' => $option->name,
]]);
}
return $array;
}
public function listAll(Request $request)
{
return view('admin.services.packs.index', [
'services' => Models\Service::all(),
]);
return view('admin.services.packs.index', ['services' => Models\Service::all()]);
}
public function listByOption(Request $request, $id)
{
$option = Models\ServiceOptions::findOrFail($id);
return view('admin.services.packs.byoption', [
'packs' => Models\ServicePack::where('option', $option->id)->get(),
'service' => Models\Service::findOrFail($option->parent_service),
'option' => $option,
'option' => Models\ServiceOptions::with('service', 'packs')->findOrFail($id)
]);
}
public function listByService(Request $request, $id)
{
return view('admin.services.packs.byservice', [
'service' => Models\Service::findOrFail($id),
'options' => Models\ServiceOptions::select(
'service_options.id',
'service_options.name',
DB::raw('(SELECT COUNT(id) FROM service_packs WHERE service_packs.option = service_options.id) AS p_count')
)->where('parent_service', $id)->get(),
'service' => Models\Service::with('options', 'options.packs')->findOrFail($id),
]);
}
public function new(Request $request, $opt = null)
{
return view('admin.services.packs.new', [
'services' => $this->formatServices(),
'packFor' => $opt,
'services' => Models\Service::with('options')->get(),
]);
}
@ -107,12 +72,18 @@ class PackController extends Controller
{
try {
$repo = new Pack;
$id = $repo->create($request->except([
'_token',
$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', $id)->withInput();
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) {
@ -127,15 +98,12 @@ class PackController extends Controller
public function edit(Request $request, $id)
{
$pack = Models\ServicePack::findOrFail($id);
$option = Models\ServiceOptions::select('id', 'parent_service', 'name')->where('id', $pack->option)->first();
$pack = Models\ServicePack::with('option.service')->findOrFail($id);
return view('admin.services.packs.edit', [
'pack' => $pack,
'services' => $this->formatServices(),
'services' => Models\Service::all()->load('options'),
'files' => Storage::files('packs/' . $pack->uuid),
'service' => Models\Service::findOrFail($option->parent_service),
'option' => $option,
]);
}
@ -159,8 +127,13 @@ class PackController extends Controller
} else {
try {
$repo = new Pack;
$repo->update($id, $request->except([
'_token',
$repo->update($id, $request->only([
'name',
'version',
'description',
'option',
'selectable',
'visible',
]));
Alert::success('Service pack has been successfully updated.')->flash();
} catch (DisplayValidationException $ex) {
@ -215,8 +188,7 @@ class PackController extends Controller
public function uploadForm(Request $request, $for = null)
{
return view('admin.services.packs.upload', [
'services' => $this->formatServices(),
'for' => $for,
'services' => Models\Service::all()->load('options'),
]);
}
@ -224,12 +196,10 @@ class PackController extends Controller
{
try {
$repo = new Pack;
$id = $repo->createWithTemplate($request->except([
'_token',
]));
$pack = $repo->createWithTemplate($request->only(['option', 'file_upload']));
Alert::success('Successfully created new service!')->flash();
return redirect()->route('admin.services.packs.edit', $id)->withInput();
return redirect()->route('admin.services.packs.edit', $pack->id)->withInput();
} catch (DisplayValidationException $ex) {
return redirect()->back()->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {

View file

@ -244,7 +244,7 @@ class ServersController extends Controller
$service = Models\Service::select('executable', 'startup')->where('id', $request->input('service'))->first();
return response()->json(Models\ServiceOptions::select('id', 'name', 'docker_image')->where('parent_service', $request->input('service'))->orderBy('name', 'asc')->get());
return response()->json(Models\ServiceOptions::select('id', 'name', 'docker_image')->where('service_id', $request->input('service'))->orderBy('name', 'asc')->get());
}
/**
@ -264,7 +264,7 @@ class ServersController extends Controller
$option = Models\ServiceOptions::select(
DB::raw('COALESCE(service_options.executable, services.executable) as executable'),
DB::raw('COALESCE(service_options.startup, services.startup) as startup')
)->leftJoin('services', 'services.id', '=', 'service_options.parent_service')
)->leftJoin('services', 'services.id', '=', 'service_options.service_id')
->where('service_options.id', $request->input('option'))
->first();

View file

@ -45,10 +45,7 @@ class ServiceController extends Controller
public function getIndex(Request $request)
{
return view('admin.services.index', [
'services' => Models\Service::select(
'services.*',
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.service = services.id) as c_servers')
)->get(),
'services' => Models\Service::withCount('servers')->get(),
]);
}
@ -61,12 +58,16 @@ class ServiceController extends Controller
{
try {
$repo = new ServiceRepository\Service;
$id = $repo->create($request->except([
'_token',
$service = $repo->create($request->only([
'name',
'description',
'file',
'executable',
'startup',
]));
Alert::success('Successfully created new service!')->flash();
return redirect()->route('admin.services.service', $id);
return redirect()->route('admin.services.service', $service->id);
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.new')->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
@ -82,11 +83,7 @@ class ServiceController extends Controller
public function getService(Request $request, $service)
{
return view('admin.services.view', [
'service' => Models\Service::findOrFail($service),
'options' => Models\ServiceOptions::select(
'service_options.*',
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.option = service_options.id) as c_servers')
)->where('parent_service', $service)->get(),
'service' => Models\Service::with('options', 'options.servers')->findOrFail($service),
]);
}
@ -94,8 +91,12 @@ class ServiceController extends Controller
{
try {
$repo = new ServiceRepository\Service;
$repo->update($service, $request->except([
'_token',
$repo->update($service, $request->only([
'name',
'description',
'file',
'executable',
'startup',
]));
Alert::success('Successfully updated this service.')->flash();
} catch (DisplayValidationException $ex) {
@ -130,16 +131,11 @@ class ServiceController extends Controller
public function getOption(Request $request, $service, $option)
{
$opt = Models\ServiceOptions::findOrFail($option);
$option = Models\ServiceOptions::with('service', 'variables')->findOrFail($option);
$option->setRelation('servers', $option->servers()->with('user')->paginate(25));
return view('admin.services.options.view', [
'service' => Models\Service::findOrFail($opt->parent_service),
'option' => $opt,
'variables' => Models\ServiceVariables::where('option_id', $option)->get(),
'servers' => Models\Server::select('servers.*', 'users.email as a_ownerEmail')
->join('users', 'users.id', '=', 'servers.owner_id')
->where('option', $option)
->paginate(10),
'option' => $option,
]);
}
@ -147,8 +143,13 @@ class ServiceController extends Controller
{
try {
$repo = new ServiceRepository\Option;
$repo->update($option, $request->except([
'_token',
$repo->update($option, $request->only([
'name',
'description',
'tag',
'executable',
'docker_image',
'startup',
]));
Alert::success('Option settings successfully updated.')->flash();
} catch (DisplayValidationException $ex) {
@ -164,13 +165,12 @@ class ServiceController extends Controller
public function deleteOption(Request $request, $service, $option)
{
try {
$service = Models\ServiceOptions::select('parent_service')->where('id', $option)->first();
$repo = new ServiceRepository\Option;
$repo->delete($option);
Alert::success('Successfully deleted that option.')->flash();
return redirect()->route('admin.services.service', $service->parent_service);
return redirect()->route('admin.services.service', $service);
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
@ -218,8 +218,7 @@ class ServiceController extends Controller
public function getNewVariable(Request $request, $service, $option)
{
return view('admin.services.options.variable', [
'service' => Models\Service::findOrFail($service),
'option' => Models\ServiceOptions::where('parent_service', $service)->where('id', $option)->firstOrFail(),
'option' => Models\ServiceOptions::with('service')->findOrFail($option),
]);
}
@ -227,8 +226,15 @@ class ServiceController extends Controller
{
try {
$repo = new ServiceRepository\Variable;
$repo->create($option, $request->except([
'_token',
$repo->create($option, $request->only([
'name',
'description',
'env_variable',
'default_value',
'user_viewable',
'user_editable',
'required',
'regex',
]));
Alert::success('Successfully added new variable to this option.')->flash();
@ -305,8 +311,9 @@ class ServiceController extends Controller
{
try {
$repo = new ServiceRepository\Service;
$repo->updateFile($serviceId, $request->except([
'_token',
$repo->updateFile($serviceId, $request->only([
'file',
'contents',
]));
return response('', 204);

View file

@ -224,7 +224,7 @@ class ServerController extends Controller
$service = Models\Service::select(
DB::raw('IFNULL(service_options.executable, services.executable) as executable')
)->leftJoin('service_options', 'service_options.parent_service', '=', 'services.id')
)->leftJoin('service_options', 'service_options.service_id', '=', 'services.id')
->where('service_options.id', $server->option_id)
->where('services.id', $server->service_id)
->first();

View file

@ -40,5 +40,38 @@ class Service extends Model
*
* @var array
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
protected $fillable = ['id', 'created_at', 'updated_at'];
/**
* Gets all service options associated with this service.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function options()
{
return $this->hasMany(ServiceOptions::class);
}
/**
* Returns all of the packs associated with a service, regardless of the service option.
*
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
*/
public function packs()
{
return $this->hasManyThrough(
'Pterodactyl\Models\ServicePack', 'Pterodactyl\Models\ServiceOptions',
'service_id', 'option_id'
);
}
/**
* Gets all servers associated with this service.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function servers()
{
return $this->hasMany(Server::class);
}
}

View file

@ -48,9 +48,29 @@ class ServiceOptions extends Model
* @var array
*/
protected $casts = [
'parent_service' => 'integer',
'service_id' => 'integer',
];
/**
* Gets service associated with a service option.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function service()
{
return $this->belongsTo(Service::class);
}
/**
* Gets all servers associated with this service option.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function servers()
{
return $this->hasMany(Server::class, 'option_id');
}
/**
* Gets all variables associated with this service.
*
@ -68,6 +88,6 @@ class ServiceOptions extends Model
*/
public function packs()
{
return $this->hasMany(ServicePack::class, 'option');
return $this->hasMany(ServicePack::class, 'option_id');
}
}

View file

@ -56,4 +56,14 @@ class ServicePack extends Model
'selectable' => 'boolean',
'visible' => 'boolean',
];
/**
* Gets option associated with a service pack.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function option()
{
return $this->belongsTo(ServiceOptions::class);
}
}

View file

@ -53,4 +53,9 @@ class ServiceVariables extends Model
'user_editable' => 'integer',
'required' => 'integer',
];
public function serverVariables()
{
return $this->hasMany(ServerVariables::class, 'variable_id');
}
}

View file

@ -62,7 +62,7 @@ class ServerObserver
$user = Models\User::findOrFail($server->owner_id);
$node = Models\Node::select('name')->where('id', $server->node_id)->first();
$service = Models\Service::select('services.name', 'service_options.name as optionName')
->join('service_options', 'service_options.parent_service', '=', 'services.id')
->join('service_options', 'service_options.service_id', '=', 'services.id')
->where('services.id', $server->service_id)
->where('service_options.id', $server->option_id)
->first();

View file

@ -163,7 +163,7 @@ class ServerRepository
// We know the service and option exists because of the validation.
// We need to verify that the option exists for the service, and then check for
// any required variable fields. (fields are labeled env_<env_variable>)
$option = Models\ServiceOptions::where('id', $data['option'])->where('parent_service', $data['service'])->first();
$option = Models\ServiceOptions::where('id', $data['option'])->where('service_id', $data['service'])->first();
if (! $option) {
throw new DisplayException('The requested service option does not exist for the specified service.');
}
@ -181,7 +181,7 @@ class ServerRepository
}
// Load up the Service Information
$service = Models\Service::find($option->parent_service);
$service = Models\Service::find($option->service_id);
// Check those Variables
$variables = Models\ServiceVariables::where('option_id', $data['option'])->get();

View file

@ -63,7 +63,7 @@ class Option
}
$option = new Models\ServiceOptions;
$option->parent_service = $service->id;
$option->service_id = $service->id;
$option->fill($data);
$option->save();

View file

@ -69,8 +69,8 @@ class Pack
try {
$uuid = new UuidService;
$pack = Models\ServicePack::create([
'option' => $data['option'],
'uuid' => $uuid->generate('servers', 'uuid'),
'option_id' => $data['option'],
'uuid' => $uuid->generate('service_packs', 'uuid'),
'name' => $data['name'],
'version' => $data['version'],
'description' => (empty($data['description'])) ? null : $data['description'],
@ -89,7 +89,7 @@ class Pack
throw $ex;
}
return $pack->id;
return $pack;
}
public function createWithTemplate(array $data)
@ -123,7 +123,7 @@ class Pack
}
$json = json_decode($zip->getFromName('import.json'));
$id = $this->create([
$pack = $this->create([
'name' => $json->name,
'version' => $json->version,
'description' => $json->description,
@ -132,7 +132,6 @@ class Pack
'visible' => $json->visible,
]);
$pack = Models\ServicePack::findOrFail($id);
if (! $zip->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) {
$pack->delete();
throw new DisplayException('Unable to extract the archive file to the correct location.');
@ -140,7 +139,7 @@ class Pack
$zip->close();
return $pack->id;
return $pack;
} else {
$json = json_decode(file_get_contents($data['file_upload']->path()));
@ -170,9 +169,8 @@ class Pack
throw new DisplayValidationException($validator->errors());
}
DB::transaction(function () use ($id, $data) {
Models\ServicePack::findOrFail($id)->update([
'option' => $data['option'],
'option_id' => $data['option'],
'name' => $data['name'],
'version' => $data['version'],
'description' => (empty($data['description'])) ? null : $data['description'],
@ -180,8 +178,7 @@ class Pack
'visible' => isset($data['visible']),
]);
return true;
});
return;
}
public function delete($id)

View file

@ -55,23 +55,18 @@ class Service
$data['author'] = env('SERVICE_AUTHOR', (string) Uuid::generate(4));
$service = new Models\Service;
DB::beginTransaction();
try {
$service->fill($data);
$service->save();
Storage::put('services/' . $data['file'] . '/main.json', '{}');
Storage::copy('services/.templates/index.js', 'services/' . $data['file'] . '/index.js');
$service = Models\Service::create($data);
Storage::put('services/' . $service->file . '/main.json', '{}');
Storage::copy('services/.templates/index.js', 'services/' . $service->file . '/index.js');
DB::commit();
} catch (\Exception $ex) {
DB::rollBack();
throw $ex;
}
return $service->id;
return $service;
}
public function update($id, array $data)
@ -99,7 +94,7 @@ class Service
{
$service = Models\Service::findOrFail($id);
$servers = Models\Server::where('service', $service->id)->get();
$options = Models\ServiceOptions::select('id')->where('parent_service', $service->id);
$options = Models\ServiceOptions::select('id')->where('service_id', $service->id);
if (count($servers) !== 0) {
throw new DisplayException('You cannot delete a service that has servers associated with it.');

View file

@ -39,7 +39,7 @@ class Variable
public function create($id, array $data)
{
$option = Models\ServiceOptions::findOrFail($id);
$option = Models\ServiceOptions::select('id')->findOrFail($id);
$validator = Validator::make($data, [
'name' => 'required|string|min:1|max:255',
@ -67,21 +67,22 @@ class Variable
$data['user_viewable'] = (isset($data['user_viewable']) && in_array((int) $data['user_viewable'], [0, 1])) ? $data['user_viewable'] : 0;
$data['user_editable'] = (isset($data['user_editable']) && in_array((int) $data['user_editable'], [0, 1])) ? $data['user_editable'] : 0;
$data['required'] = (isset($data['required']) && in_array((int) $data['required'], [0, 1])) ? $data['required'] : 0;
$data['option_id'] = $option->id;
$variable = new Models\ServiceVariables;
$variable->option_id = $option->id;
$variable->fill($data);
$variable = Models\ServiceVariables::create($data);
return $variable->save();
return $variable;
}
public function delete($id)
{
$variable = Models\ServiceVariables::findOrFail($id);
$variable = Models\ServiceVariables::with('serverVariables')->findOrFail($id);
DB::beginTransaction();
try {
Models\ServerVariables::where('variable_id', $variable->id)->delete();
foreach($variable->serverVariables as $svar) {
$svar->delete();
}
$variable->delete();
DB::commit();
@ -125,7 +126,18 @@ class Variable
$data['user_editable'] = (isset($data['user_editable']) && in_array((int) $data['user_editable'], [0, 1])) ? $data['user_editable'] : $variable->user_editable;
$data['required'] = (isset($data['required']) && in_array((int) $data['required'], [0, 1])) ? $data['required'] : $variable->required;
$variable->fill($data);
// Not using $data because the function that passes into this function
// can't do $requst->only() due to the page setup.
$variable->fill([
'name' => $data['name'],
'description' => $data['description'],
'env_variable' => $data['env_variable'],
'default_value' => $data['default_value'],
'user_viewable' => $data['user_viewable'],
'user_editable' => $data['user_editable'],
'required' => $data['required'],
'regex' => $data['regex'],
]);
return $variable->save();
}

View file

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AdjustColumnNames extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('service_options', function (Blueprint $table) {
$table->dropForeign('service_options_parent_service_foreign');
$table->dropIndex('service_options_parent_service_foreign');
$table->renameColumn('parent_service', 'service_id');
$table->foreign('service_id')->references('id')->on('services');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('service_options', function (Blueprint $table) {
$table->dropForeign('service_options_service_id_foreign');
$table->dropIndex('service_options_service_id_foreign');
$table->renameColumn('service_id', 'parent_service');
$table->foreign('parent_service')->references('id')->on('services');
});
}
}

View file

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AdjustColumnNamesForServicePacks extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('service_packs', function (Blueprint $table) {
$table->dropForeign('service_packs_option_foreign');
$table->dropIndex('service_packs_option_foreign');
$table->renameColumn('option', 'option_id');
$table->foreign('option_id')->references('id')->on('service_options');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('service_packs', function (Blueprint $table) {
$table->dropForeign('service_packs_option_id_foreign');
$table->dropIndex('service_packs_option_id_foreign');
$table->renameColumn('option_id', 'option');
$table->foreign('option')->references('id')->on('service_options');
});
}
}

View file

@ -44,7 +44,7 @@
<tr>
<td><a href="{{ route('admin.services.service', $service->id) }}">{{ $service->name }}</a></td>
<td>{!! $service->description !!}</td>
<td class="text-center">{{ $service->c_servers }}</td>
<td class="text-center">{{ $service->servers_count }}</td>
<td class="text-center align-middle"><a href="{{ route('admin.services.service.config', $service->id) }}"><button class="btn btn-xxs btn-primary"><i class="fa fa-wrench"></i> Configure</button></a></td>
</tr>
@endforeach

View file

@ -28,12 +28,12 @@
<ul class="breadcrumb">
<li><a href="/admin">Admin Control</a></li>
<li><a href="/admin/services">Services</a></li>
<li><a href="{{ route('admin.services.service', $service->id) }}">{{ $service->name }}</a></li>
<li><a href="{{ route('admin.services.option', [$service->id, $option->id]) }}">{{ $option->name }}</a></li>
<li><a href="{{ route('admin.services.service', $option->service->id) }}">{{ $option->service->name }}</a></li>
<li><a href="{{ route('admin.services.option', [$option->service->id, $option->id]) }}">{{ $option->name }}</a></li>
<li class="active">New Variable</li>
</ul>
<h3>New Option Variable</h3><hr />
<form action="{{ route('admin.services.option.variable.new', [$service->id, $option->id]) }}" method="POST">
<form action="{{ route('admin.services.option.variable.new', [$option->service->id, $option->id]) }}" method="POST">
<div class="well">
<div class="row">
<div class="col-md-12 form-group">

View file

@ -28,12 +28,12 @@
<ul class="breadcrumb">
<li><a href="/admin">Admin Control</a></li>
<li><a href="/admin/services">Services</a></li>
<li><a href="{{ route('admin.services.service', $service->id) }}">{{ $service->name }}</a></li>
<li><a href="{{ route('admin.services.service', $option->service->id) }}">{{ $option->service->name }}</a></li>
<li class="active">{{ $option->name }}</li>
</ul>
<div class="alert alert-warning"><strong>Warning!</strong> This page contains advanced settings that the panel and daemon use to control servers. Modifying information on this page is not recommended unless you are absolutely sure of what you are doing.</div>
<h3>Settings</h3><hr />
<form action="{{ route('admin.services.option', [$service->id, $option->id]) }}" method="POST">
<form action="{{ route('admin.services.option', [$option->service->id, $option->id]) }}" method="POST">
<div class="row">
<div class="col-md-6 form-group">
<label class="control-label">Name:</label>
@ -74,7 +74,7 @@
<div class="col-md-12 form-group">
<label class="control-label">Default Startup Command:</label>
<div>
<input type="text" name="startup" value="{{ old('startup', $option->startup) }}" class="form-control" />
<input type="text" name="startup" value="{{ old('startup', $option->startup) }}" placeholder="{{ $option->service->startup }}" class="form-control" />
<p class="text-muted"><small>To use the default startup of the parent service simply leave this field blank.</small></p>
</div>
</div>
@ -88,9 +88,9 @@
</div>
</div>
</form>
<h3>Variables <small><a href="{{ route('admin.services.option.variable.new', [$service->id, $option->id]) }}"><i class="fa fa-plus"></i></a></small></h3><hr />
@foreach($variables as $variable)
<form action="{{ route('admin.services.option.variable', [$service->id, $option->id, $variable->id]) }}" method="POST">
<h3>Variables <small><a href="{{ route('admin.services.option.variable.new', [$option->service->id, $option->id]) }}"><i class="fa fa-plus"></i></a></small></h3><hr />
@foreach($option->variables as $variable)
<form action="{{ route('admin.services.option.variable', [$option->service->id, $option->id, $variable->id]) }}" method="POST">
<div class="well">
<div class="row">
<div class="col-md-6 form-group">
@ -158,7 +158,7 @@
<div class="row">
<div class="col-md-12">
{!! csrf_field() !!}
<a href="{{ route('admin.services.option.variable.delete', [$service->id, $option->id, $variable->id]) }}"><button type="button" class="btn btn-sm btn-danger pull-right"><i class="fa fa-times"></i></button></a>
<a href="{{ route('admin.services.option.variable.delete', [$option->service->id, $option->id, $variable->id]) }}"><button type="button" class="btn btn-sm btn-danger pull-right"><i class="fa fa-times"></i></button></a>
<input type="submit" class="btn btn-sm btn-success" value="Update Variable" />
</div>
</div>
@ -175,16 +175,19 @@
</tr>
</thead>
<tbody>
@foreach ($servers as $server)
@foreach ($option->servers as $server)
<tr>
<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>
<td><a href="{{ route('admin.users.view', $server->owner_id) }}">{{ $server->a_ownerEmail }}</a></td>
<td><a href="{{ route('admin.users.view', $server->owner_id) }}">{{ $server->user->email }}</a></td>
<td>{{ $server->updated_at }}</td>
</tr>
@endforeach
</tbody>
</table>
<form action="{{ route('admin.services.option', [$service->id, $option->id]) }}" method="POST">
<div class="text-center">
{!! $option->servers->render() !!}
</div>
<form action="{{ route('admin.services.option', [$option->service->id, $option->id]) }}" method="POST">
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger">

View file

@ -29,7 +29,7 @@
<li><a href="/admin">Admin Control</a></li>
<li><a href="/admin/services">Services</a></li>
<li><a href="{{ route('admin.services.packs') }}">Packs</a></li>
<li><a href="{{ route('admin.services.packs.service', $service->id) }}">{{ $service->name }}</a></li>
<li><a href="{{ route('admin.services.packs.service', $option->service->id) }}">{{ $option->service->name }}</a></li>
<li class="active">{{ $option->name }}</li>
</ul>
<h3 class="nopad">Service Packs</h3><hr />
@ -44,7 +44,7 @@
</tr>
</thead>
<tbody>
@foreach ($packs as $pack)
@foreach ($option->packs as $pack)
<tr>
<td><a href="{{ route('admin.services.packs.edit', $pack->id) }}">{{ $pack->name }}</a></td>
<td><code>{{ $pack->version }}</code></td>

View file

@ -40,10 +40,10 @@
</tr>
</thead>
<tbody>
@foreach ($options as $option)
@foreach ($service->options as $option)
<tr>
<td><a href="{{ route('admin.services.packs.option', $option->id) }}">{{ $option->name }}</a></td>
<td>{{ $option->p_count }}</td>
<td>{{ $option->packs->count() }}</td>
</tr>
@endforeach
<tr>

View file

@ -29,8 +29,8 @@
<li><a href="/admin">Admin Control</a></li>
<li><a href="/admin/services">Services</a></li>
<li><a href="{{ route('admin.services.packs') }}">Packs</a></li>
<li><a href="{{ route('admin.services.packs.service', $service->id) }}">{{ $service->name }}</a></li>
<li><a href="{{ route('admin.services.packs.option', $option->id) }}">{{ $option->name }}</a></li>
<li><a href="{{ route('admin.services.packs.service', $pack->option->service->id) }}">{{ $pack->option->service->name }}</a></li>
<li><a href="{{ route('admin.services.packs.option', $pack->option->id) }}">{{ $pack->option->name }}</a></li>
<li class="active">{{ $pack->name }} ({{ $pack->version }})</li>
</ul>
<h3 class="nopad">Manage Service Pack</h3><hr />
@ -62,10 +62,10 @@
<div class="col-md-6">
<label class="control-label">Associated Service Option:</label>
<select name="option" class="form-control">
@foreach($services as $service => $options)
<option disabled>{{ $service }}</option>
@foreach($options as $option)
<option value="{{ $option['id'] }}" @if($pack->option === (int) $option['id'])selected="selected"@endif>&nbsp;&nbsp; -- {{ $option['name'] }}</option>
@foreach($services as $service)
<option disabled>{{ $service->name }}</option>
@foreach($service->options as $option)
<option value="{{ $option->id }}" @if($pack->option_id === $option->id)selected="selected"@endif>&nbsp;&nbsp; -- {{ $option->name }}</option>
@endforeach
@endforeach
</select>

View file

@ -59,10 +59,10 @@
<div class="col-md-6">
<label class="control-label">Associated Service Option:</label>
<select name="option" class="form-control">
@foreach($services as $service => $options)
<option disabled>{{ $service }}</option>
@foreach($options as $option)
<option value="{{ $option['id'] }}" @if((int) $packFor === (int) $option['id'])selected="selected"@endif>&nbsp;&nbsp; -- {{ $option['name'] }}</option>
@foreach($services as $service)
<option disabled>{{ $service->name }}</option>
@foreach($service->options as $option)
<option value="{{ $option->id }}" @if((int) request()->option === $option->id)selected="selected"@endif>&nbsp;&nbsp; -- {{ $option->name }}</option>
@endforeach
@endforeach
</select>

View file

@ -12,10 +12,10 @@
<div class="col-md-12">
<label class="control-label">Associated Service Option:</label>
<select name="option" class="form-control">
@foreach($services as $service => $options)
<option disabled>{{ $service }}</option>
@foreach($options as $option)
<option value="{{ $option['id'] }}" @if((int) $for === (int) $option['id'])selected="selected"@endif>&nbsp;&nbsp; -- {{ $option['name'] }}</option>
@foreach($services as $service)
<option disabled>{{ $service->name }}</option>
@foreach($service->options as $option)
<option value="{{ $option->id }}" @if((int) request()->option === $option->id)selected="selected"@endif>&nbsp;&nbsp; -- {{ $option->name }}</option>
@endforeach
@endforeach
</select>

View file

@ -41,12 +41,12 @@
</tr>
</thead>
<tbody>
@foreach($options as $option)
@foreach($service->options as $option)
<tr>
<td><a href="{{ route('admin.services.option', [ $service->id, $option->id]) }}">{{ $option->name }}</a></td>
<td>{!! $option->description !!}</td>
<td><code>{{ $option->tag }}</code></td>
<td class="text-center">{{ $option->c_servers }}</td>
<td class="text-center">{{ $option->servers->count() }}</td>
</tr>
@endforeach
<tr>