From 32c21baab0964f2c9dd8a93b7c32ad2c8dbc4f88 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 2 Feb 2017 16:01:18 -0500 Subject: [PATCH] Return packs associated with a service when viewing it on the API. --- app/Http/Controllers/API/ServiceController.php | 1 + app/Models/ServiceOptions.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/app/Http/Controllers/API/ServiceController.php b/app/Http/Controllers/API/ServiceController.php index aa8b4ac29..257ace766 100755 --- a/app/Http/Controllers/API/ServiceController.php +++ b/app/Http/Controllers/API/ServiceController.php @@ -55,6 +55,7 @@ class ServiceController extends BaseController 'options' => Models\ServiceOptions::select('id', 'name', 'description', 'tag', 'docker_image') ->where('parent_service', $service->id) ->with('variables') + ->with('packs') ->get(), ]; } diff --git a/app/Models/ServiceOptions.php b/app/Models/ServiceOptions.php index fe7e23f10..9b4a3a7ae 100644 --- a/app/Models/ServiceOptions.php +++ b/app/Models/ServiceOptions.php @@ -60,4 +60,14 @@ class ServiceOptions extends Model { return $this->hasMany(ServiceVariables::class, 'option_id'); } + + /** + * Gets all packs associated with this service. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function packs() + { + return $this->hasMany(ServicePack::class, 'option'); + } }