Log in functionality

This commit is contained in:
Peter Papp
2021-03-15 09:23:53 +01:00
parent 6b67f861c3
commit ba902a30b3
16 changed files with 182 additions and 160 deletions

View File

@@ -20,65 +20,51 @@ class UserResource extends JsonResource
{
// TODO: zrefaktorovat
return [
'data' => [
'id' => (string)$this->id,
'type' => 'user',
'attributes' => [
'data' => [
'id' => $this->id,
'type' => 'user',
'attributes' => [
'storage_capacity' => $this->settings->storage_capacity,
'subscription' => $this->subscribed('main'),
'incomplete_payment' => $this->hasIncompletePayment('main') ? route('cashier.payment', $this->subscription('main')->latestPayment()->id) : null,
'stripe_customer' => is_null($this->stripe_id) ? false : true,
'email' => env('APP_DEMO') ? obfuscate_email($this->email) : $this->email,
'role' => $this->role,
'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,
],
'relationships' => [
'settings' => [
'data' => [
'id' => $this->id,
'type' => 'settings',
'attributes' => [
'avatar' => $this->settings->avatar,
'billing_name' => $this->settings->name,
'billing_address' => $this->settings->address,
'billing_state' => $this->settings->state,
'billing_city' => $this->settings->city,
'billing_postal_code' => $this->settings->postal_code,
'billing_country' => $this->settings->country,
'billing_phone_number' => $this->settings->phone_number,
'timezone' => $this->settings->timezone
]
]
],
'favourites' => [
'data' => [
'id' => $this->id,
'type' => 'favourite_folders',
'attributes' => [
'folders' => $this->favouriteFolders->makeHidden(['pivot'])
],
],
]
]
],
'relationships' => [
'settings' => [
'data' => [
'id' => $this->settings->user_id,
'type' => 'settings',
'attributes' => [
'avatar' => $this->settings->avatar,
'billing_name' => $this->settings->name,
'billing_address' => $this->settings->address,
'billing_state' => $this->settings->state,
'billing_city' => $this->settings->city,
'billing_postal_code' => $this->settings->postal_code,
'billing_country' => $this->settings->country,
'billing_phone_number' => $this->settings->phone_number,
'timezone' => $this->settings->timezone
]
]
],
'storage' => [
'data' => [
'id' => '1',
'type' => 'storage',
'attributes' => $this->storage
]
],
'favourites' => [
'data' => [
'id' => '1',
'type' => 'folders_favourite',
'attributes' => [
'folders' => $this->favouriteFolders->makeHidden(['pivot'])
],
],
],
'tree' => [
'data' => [
'id' => '1',
'type' => 'folders_tree',
'attributes' => [
'folders' => $this->folder_tree
],
],
],
]
];
}
}