Completed model updates for Services
This commit is contained in:
parent
09d23deed6
commit
323f1d943f
26 changed files with 299 additions and 167 deletions
|
@ -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.');
|
||||
|
|
Reference in a new issue