Skip to content

Commit 32c21ba

Browse files
committed
Return packs associated with a service when viewing it on the API.
1 parent 6220f71 commit 32c21ba

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

app/Http/Controllers/API/ServiceController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function view(Request $request, $id)
5555
'options' => Models\ServiceOptions::select('id', 'name', 'description', 'tag', 'docker_image')
5656
->where('parent_service', $service->id)
5757
->with('variables')
58+
->with('packs')
5859
->get(),
5960
];
6061
}

app/Models/ServiceOptions.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,14 @@ public function variables()
6060
{
6161
return $this->hasMany(ServiceVariables::class, 'option_id');
6262
}
63+
64+
/**
65+
* Gets all packs associated with this service.
66+
*
67+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
68+
*/
69+
public function packs()
70+
{
71+
return $this->hasMany(ServicePack::class, 'option');
72+
}
6373
}

0 commit comments

Comments
 (0)