Singularize model names.
This commit is contained in:
parent
7c916ad38f
commit
8ba479e51f
25 changed files with 73 additions and 73 deletions
|
@ -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) {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue