From 58796e7441862774127d8971407187e20fae503a Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 3 Aug 2019 12:56:32 -0700 Subject: [PATCH] Fix Server model to use correct relationship when returning subusers, closes #1589 --- CHANGELOG.md | 1 + app/Models/Server.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52388083a..a880196b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ value when showing an error state. * Database host management will now properly display an error message to the user when there is any type of MySQL related error encountered during creation or update. * Two-factor tokens generated when a company name has a space in it will now properly be parsed on iOS authenticator devices. +* Fixed 500 error when trying to request subuser's from a server in the application API. ### Added * Server listing view now displays the total used disk space for each server. diff --git a/app/Models/Server.php b/app/Models/Server.php index b1a77ead8..7c2adf047 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -156,11 +156,11 @@ class Server extends Model implements CleansAttributes, ValidableContract /** * Gets the subusers associated with a server. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough */ public function subusers() { - return $this->hasMany(Subuser::class); + return $this->hasManyThrough(User::class, Subuser::class, 'server_id', 'id', 'id', 'user_id'); } /**