diff --git a/src/App/Users/Resources/SettingsResource.php b/src/App/Users/Resources/SettingsResource.php new file mode 100644 index 00000000..5e09ce3b --- /dev/null +++ b/src/App/Users/Resources/SettingsResource.php @@ -0,0 +1,36 @@ + [ + 'id' => $this->id, + 'type' => 'settings', + 'attributes' => [ + 'avatar' => $this->avatar, + 'name' => $this->name, + 'address' => $this->address, + 'state' => $this->state, + 'city' => $this->city, + 'postal_code' => $this->postal_code, + 'country' => $this->country, + 'phone_number' => $this->phone_number, + 'timezone' => $this->timezone, + ], + ], + ]; + } + + +} diff --git a/src/App/Users/Resources/UserResource.php b/src/App/Users/Resources/UserResource.php index 150dedcb..0803e2f4 100644 --- a/src/App/Users/Resources/UserResource.php +++ b/src/App/Users/Resources/UserResource.php @@ -1,8 +1,10 @@ [ - 'id' => $this->id, - 'type' => 'user', - 'attributes' => [ - 'max_storage_amount' => $this->settings->max_storage_amount, - 'email' => is_demo() ? obfuscate_email($this->email) : $this->email, - 'role' => $this->role, - 'two_factor_authentication' => $this->two_factor_secret ? true : false, - 'folders' => $this->folder_tree, - 'storage' => $this->storage, - 'created_at_formatted' => format_date($this->created_at, '%d. %B. %Y'), - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, + 'id' => $this->id, + 'type' => 'user', + 'attributes' => [ + 'max_storage_amount' => $this->settings->max_storage_amount, + 'email' => is_demo() ? obfuscate_email($this->email) : $this->email, + 'role' => $this->role, + 'two_factor_authentication' => $this->two_factor_secret ? true : false, + 'folders' => $this->folder_tree, + 'storage' => $this->storage, + 'created_at' => format_date($this->created_at, '%d. %B. %Y'), + 'updated_at' => format_date($this->updated_at, '%d. %B. %Y'), ], 'relationships' => [ - 'settings' => [ - 'data' => [ - 'id' => $this->id, - 'type' => 'settings', - 'attributes' => [ - 'avatar' => $this->settings->avatar, - 'name' => $this->settings->name, - 'address' => $this->settings->address, - 'state' => $this->settings->state, - 'city' => $this->settings->city, - 'postal_code' => $this->settings->postal_code, - 'country' => $this->settings->country, - 'phone_number' => $this->settings->phone_number, - 'timezone' => $this->settings->timezone, - ], - ], - ], + 'settings' => new SettingsResource($this->settings), 'favourites' => new FolderCollection($this->favouriteFolders), + $this->mergeWhen($this->hasSubscription(), fn() => [ + 'subscription' => new SubscriptionResource($this->subscription), + ]), ], ], ]; } + + }