mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-06 02:33:48 +00:00
51 lines
2.0 KiB
PHP
51 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Users\Resources;
|
|
|
|
use Domain\Folders\Resources\FolderCollection;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use VueFileManager\Subscription\Domain\Subscriptions\Resources\SubscriptionResource;
|
|
|
|
class UserResource 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' => 'user',
|
|
'attributes' => [
|
|
'avatar' => $this->settings->avatar,
|
|
'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' => new SettingsResource($this->settings),
|
|
'favourites' => new FolderCollection($this->favouriteFolders),
|
|
'limitations' => [
|
|
'id' => $this->id,
|
|
'type' => 'limitations',
|
|
'data' => [
|
|
'attributes' => $this->limitations,
|
|
],
|
|
],
|
|
$this->mergeWhen($this->hasSubscription(), fn() => [
|
|
'subscription' => new SubscriptionResource($this->subscription),
|
|
]),
|
|
],
|
|
],
|
|
];
|
|
}
|
|
}
|