From 824041f6ca30defacf585cb7b37d01533eff3764 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 17 Feb 2017 20:40:50 -0500 Subject: [PATCH] Fix service creation/updates, closes #306 --- CHANGELOG.md | 1 + app/Models/Service.php | 6 ++++-- app/Repositories/ServiceRepository/Service.php | 8 +++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1334a5e54..3c186e143 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. * `[pre.2]` — Fixes inability to delete accounts due to SQL changes. * `[pre.2]` — Fixes bug with checking power-permissions that showed the wrong buttons. Also adds check back to sidebar to only show options a user can use. * `[pre.2]` — Fixes allocation listing on node allocations tab as well as bug preventing deletion of port. +* `[pre.2]` — Fixes bug in services that prevented saving updated settings or creating new services. ### Changed * `[pre.2]` — File Manager now displays relevant information on all screen sizes, and includes better button clicking mechanics for dropdown menu. diff --git a/app/Models/Service.php b/app/Models/Service.php index 39e74e5b8..83cdb70b0 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -36,11 +36,13 @@ class Service extends Model protected $table = 'services'; /** - * Fields that are not mass assignable. + * Fields that are mass assignable. * * @var array */ - protected $fillable = ['id', 'created_at', 'updated_at']; + protected $fillable = [ + 'name', 'description', 'file', 'executable', 'startup', + ]; /** * Gets all service options associated with this service. diff --git a/app/Repositories/ServiceRepository/Service.php b/app/Repositories/ServiceRepository/Service.php index 6ebb76142..206479a0a 100644 --- a/app/Repositories/ServiceRepository/Service.php +++ b/app/Repositories/ServiceRepository/Service.php @@ -53,11 +53,13 @@ class Service throw new DisplayValidationException($validator->errors()); } - $data['author'] = env('SERVICE_AUTHOR', (string) Uuid::generate(4)); - DB::beginTransaction(); try { - $service = Models\Service::create($data); + $service = new Models\Service; + $service->author = env('SERVICE_AUTHOR', (string) Uuid::generate(4)); + $service->fill($data); + $service->save(); + Storage::put('services/' . $service->file . '/main.json', '{}'); Storage::copy('services/.templates/index.js', 'services/' . $service->file . '/index.js'); DB::commit();