Singularize model names.

This commit is contained in:
Dane Everitt 2017-02-12 16:02:23 -05:00
parent 7c916ad38f
commit 8ba479e51f
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
25 changed files with 73 additions and 73 deletions

View file

@ -49,7 +49,7 @@ class PackController extends Controller
public function listByOption(Request $request, $id)
{
return view('admin.services.packs.byoption', [
'option' => Models\ServiceOptions::with('service', 'packs')->findOrFail($id),
'option' => Models\ServiceOption::with('service', 'packs')->findOrFail($id),
]);
}

View file

@ -152,7 +152,7 @@ class ServersController extends Controller
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\View
*/
public function postNewServerServiceOptions(Request $request)
public function postNewServerServiceOption(Request $request)
{
if (! $request->input('service')) {
return response()->json([
@ -162,7 +162,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('service_id', $request->input('service'))->orderBy('name', 'asc')->get());
return response()->json(Models\ServiceOption::select('id', 'name', 'docker_image')->where('service_id', $request->input('service'))->orderBy('name', 'asc')->get());
}
/**
@ -179,7 +179,7 @@ class ServersController extends Controller
], 500);
}
$option = Models\ServiceOptions::with('variables')->with(['packs' => function ($query) {
$option = Models\ServiceOption::with('variables')->with(['packs' => function ($query) {
$query->where('selectable', true);
}])->findOrFail($request->input('option'));

View file

@ -124,7 +124,7 @@ class ServiceController extends Controller
public function getOption(Request $request, $service, $option)
{
$option = Models\ServiceOptions::with('service', 'variables')->findOrFail($option);
$option = Models\ServiceOption::with('service', 'variables')->findOrFail($option);
$option->setRelation('servers', $option->servers()->with('user')->paginate(25));
return view('admin.services.options.view', ['option' => $option]);
@ -205,7 +205,7 @@ class ServiceController extends Controller
public function getNewVariable(Request $request, $service, $option)
{
return view('admin.services.options.variable', [
'option' => Models\ServiceOptions::with('service')->findOrFail($option),
'option' => Models\ServiceOption::with('service')->findOrFail($option),
]);
}

View file

@ -214,7 +214,7 @@ class ServerController extends Controller
}]);
$this->authorize('view-startup', $server);
$variables = Models\ServiceVariables::select(
$variables = Models\ServiceVariable::select(
'service_variables.*',
DB::raw('COALESCE(server_variables.variable_value, service_variables.default_value) as a_serverValue')
)->leftJoin('server_variables', 'server_variables.variable_id', '=', 'service_variables.id')

View file

@ -144,7 +144,7 @@ class AdminRoutes
]);
$router->post('/new/service-options', [
'uses' => 'Admin\ServersController@postNewServerServiceOptions',
'uses' => 'Admin\ServersController@postNewServerServiceOption',
]);
$router->post('/new/option-details', [

View file

@ -253,7 +253,7 @@ class Server extends Model
*/
public function option()
{
return $this->belongsTo(ServiceOptions::class);
return $this->belongsTo(ServiceOption::class);
}
/**

View file

@ -59,6 +59,6 @@ class ServerVariables extends Model
*/
public function variable()
{
return $this->belongsTo(ServiceVariables::class, 'variable_id');
return $this->belongsTo(ServiceVariable::class, 'variable_id');
}
}

View file

@ -49,7 +49,7 @@ class Service extends Model
*/
public function options()
{
return $this->hasMany(ServiceOptions::class);
return $this->hasMany(ServiceOption::class);
}
/**
@ -60,7 +60,7 @@ class Service extends Model
public function packs()
{
return $this->hasManyThrough(
'Pterodactyl\Models\ServicePack', 'Pterodactyl\Models\ServiceOptions',
'Pterodactyl\Models\ServicePack', 'Pterodactyl\Models\ServiceOption',
'service_id', 'option_id'
);
}

View file

@ -26,7 +26,7 @@ namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Model;
class ServiceOptions extends Model
class ServiceOption extends Model
{
/**
* The table associated with the model.
@ -100,7 +100,7 @@ class ServiceOptions extends Model
*/
public function variables()
{
return $this->hasMany(ServiceVariables::class, 'option_id');
return $this->hasMany(ServiceVariable::class, 'option_id');
}
/**

View file

@ -64,6 +64,6 @@ class ServicePack extends Model
*/
public function option()
{
return $this->belongsTo(ServiceOptions::class);
return $this->belongsTo(ServiceOption::class);
}
}

View file

@ -26,7 +26,7 @@ namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Model;
class ServiceVariables extends Model
class ServiceVariable extends Model
{
/**
* The table associated with the model.

View file

@ -159,7 +159,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('service_id', $data['service'])->first();
$option = Models\ServiceOption::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.');
}
@ -180,7 +180,7 @@ class ServerRepository
$service = Models\Service::find($option->service_id);
// Check those Variables
$variables = Models\ServiceVariables::where('option_id', $data['option_id'])->get();
$variables = Models\ServiceVariable::where('option_id', $data['option_id'])->get();
$variableList = [];
if ($variables) {
foreach ($variables as $variable) {

View file

@ -62,7 +62,7 @@ class Option
$data['startup'] = null;
}
$option = new Models\ServiceOptions;
$option = new Models\ServiceOption;
$option->service_id = $service->id;
$option->fill($data);
$option->save();
@ -72,7 +72,7 @@ class Option
public function delete($id)
{
$option = Models\ServiceOptions::findOrFail($id);
$option = Models\ServiceOption::findOrFail($id);
$servers = Models\Server::where('option', $option->id)->get();
if (count($servers) !== 0) {
@ -82,7 +82,7 @@ class Option
DB::beginTransaction();
try {
Models\ServiceVariables::where('option_id', $option->id)->delete();
Models\ServiceVariable::where('option_id', $option->id)->delete();
$option->delete();
DB::commit();
@ -94,7 +94,7 @@ class Option
public function update($id, array $data)
{
$option = Models\ServiceOptions::findOrFail($id);
$option = Models\ServiceOption::findOrFail($id);
$validator = Validator::make($data, [
'name' => 'sometimes|required|string|max:255',

View file

@ -94,7 +94,7 @@ class Service
{
$service = Models\Service::findOrFail($id);
$servers = Models\Server::where('service', $service->id)->get();
$options = Models\ServiceOptions::select('id')->where('service_id', $service->id);
$options = Models\ServiceOption::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.');
@ -102,7 +102,7 @@ class Service
DB::beginTransaction();
try {
Models\ServiceVariables::whereIn('option_id', $options->get()->toArray())->delete();
Models\ServiceVariable::whereIn('option_id', $options->get()->toArray())->delete();
$options->delete();
$service->delete();

View file

@ -39,7 +39,7 @@ class Variable
public function create($id, array $data)
{
$option = Models\ServiceOptions::select('id')->findOrFail($id);
$option = Models\ServiceOption::select('id')->findOrFail($id);
$validator = Validator::make($data, [
'name' => 'required|string|min:1|max:255',
@ -60,7 +60,7 @@ class Variable
throw new DisplayException('The default value you entered cannot violate the regex requirements.');
}
if (Models\ServiceVariables::where('env_variable', $data['env_variable'])->where('option_id', $option->id)->first()) {
if (Models\ServiceVariable::where('env_variable', $data['env_variable'])->where('option_id', $option->id)->first()) {
throw new DisplayException('An environment variable with that name already exists for this option.');
}
@ -69,14 +69,14 @@ class Variable
$data['required'] = (isset($data['required']) && in_array((int) $data['required'], [0, 1])) ? $data['required'] : 0;
$data['option_id'] = $option->id;
$variable = Models\ServiceVariables::create($data);
$variable = Models\ServiceVariable::create($data);
return $variable;
}
public function delete($id)
{
$variable = Models\ServiceVariables::with('serverVariables')->findOrFail($id);
$variable = Models\ServiceVariable::with('serverVariables')->findOrFail($id);
DB::beginTransaction();
try {
@ -94,7 +94,7 @@ class Variable
public function update($id, array $data)
{
$variable = Models\ServiceVariables::findOrFail($id);
$variable = Models\ServiceVariable::findOrFail($id);
$validator = Validator::make($data, [
'name' => 'sometimes|required|string|min:1|max:255',
@ -118,7 +118,7 @@ class Variable
throw new DisplayException('The default value you entered cannot violate the regex requirements.');
}
if (Models\ServiceVariables::where('id', '!=', $variable->id)->where('env_variable', $data['env_variable'])->where('option_id', $variable->option_id)->first()) {
if (Models\ServiceVariable::where('id', '!=', $variable->id)->where('env_variable', $data['env_variable'])->where('option_id', $variable->option_id)->first()) {
throw new DisplayException('An environment variable with that name already exists for this option.');
}