mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
67 lines
2.8 KiB
PHP
67 lines
2.8 KiB
PHP
<?php
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class UserResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
// TODO: zrefaktorovat
|
|
return [
|
|
'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' => 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,
|
|
],
|
|
'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,
|
|
],
|
|
],
|
|
],
|
|
'favourites' => [
|
|
'data' => [
|
|
'id' => $this->id,
|
|
'type' => 'favourite_folders',
|
|
'attributes' => [
|
|
'folders' => $this->favouriteFolders->makeHidden(['pivot']),
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
}
|