mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-29 15:44:41 +00:00
append subscription to the UserResource.php
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Users\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class SettingsResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'data' => [
|
||||||
|
'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,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Users\Resources;
|
namespace App\Users\Resources;
|
||||||
|
|
||||||
use Domain\Folders\Resources\FolderCollection;
|
use Domain\Folders\Resources\FolderCollection;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
use VueFileManager\Subscription\Domain\Subscriptions\Resources\SubscriptionResource;
|
||||||
|
|
||||||
class UserResource extends JsonResource
|
class UserResource extends JsonResource
|
||||||
{
|
{
|
||||||
@@ -17,40 +19,28 @@ class UserResource extends JsonResource
|
|||||||
// TODO: zrefaktorovat
|
// TODO: zrefaktorovat
|
||||||
return [
|
return [
|
||||||
'data' => [
|
'data' => [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'type' => 'user',
|
'type' => 'user',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'max_storage_amount' => $this->settings->max_storage_amount,
|
'max_storage_amount' => $this->settings->max_storage_amount,
|
||||||
'email' => is_demo() ? obfuscate_email($this->email) : $this->email,
|
'email' => is_demo() ? obfuscate_email($this->email) : $this->email,
|
||||||
'role' => $this->role,
|
'role' => $this->role,
|
||||||
'two_factor_authentication' => $this->two_factor_secret ? true : false,
|
'two_factor_authentication' => $this->two_factor_secret ? true : false,
|
||||||
'folders' => $this->folder_tree,
|
'folders' => $this->folder_tree,
|
||||||
'storage' => $this->storage,
|
'storage' => $this->storage,
|
||||||
'created_at_formatted' => format_date($this->created_at, '%d. %B. %Y'),
|
'created_at' => format_date($this->created_at, '%d. %B. %Y'),
|
||||||
'created_at' => $this->created_at,
|
'updated_at' => format_date($this->updated_at, '%d. %B. %Y'),
|
||||||
'updated_at' => $this->updated_at,
|
|
||||||
],
|
],
|
||||||
'relationships' => [
|
'relationships' => [
|
||||||
'settings' => [
|
'settings' => new SettingsResource($this->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,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'favourites' => new FolderCollection($this->favouriteFolders),
|
'favourites' => new FolderCollection($this->favouriteFolders),
|
||||||
|
$this->mergeWhen($this->hasSubscription(), fn() => [
|
||||||
|
'subscription' => new SubscriptionResource($this->subscription),
|
||||||
|
]),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user