- balance implementation

- invoice refactoring
This commit is contained in:
Čarodej
2021-12-15 11:24:41 +01:00
parent 6cb3503870
commit b368d56bbc
14 changed files with 197 additions and 150 deletions
+16 -4
View File
@@ -1,4 +1,5 @@
<?php
namespace App\Users\Resources;
use Domain\Folders\Resources\FolderCollection;
@@ -30,20 +31,31 @@ class UserResource extends JsonResource
'updated_at' => format_date($this->updated_at, '%d. %B. %Y'),
],
'relationships' => [
'balance' => [
'data' => [
'id' => $this->balance->id,
'type' => 'balance',
'attributes' => [
'formatted' => format_currency($this->balance->amount, $this->balance->currency),
'balance' => $this->balance->amount,
'currency' => $this->balance->currency,
],
],
],
'settings' => new SettingsResource($this->settings),
'favourites' => new FolderCollection($this->favouriteFolders),
'limitations' => [
'id' => $this->id,
'type' => 'limitations',
'data' => [
'id' => $this->id,
'type' => 'limitations',
'attributes' => $this->limitations,
],
],
$this->mergeWhen($this->hasSubscription(), fn () => [
$this->mergeWhen($this->hasSubscription(), fn() => [
'subscription' => new SubscriptionResource($this->subscription),
]),
],
'meta' => [
'meta' => [
'limitations' => $this->limitations->summary(),
],
],