refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
43
app/Http/Resources/Account/User/User.php
Normal file
43
app/Http/Resources/Account/User/User.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Account\User;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
use App\Http\Resources\Settings\Currency\Currency as CurrencyResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\User\User>
|
||||
*/
|
||||
class User extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'user',
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'me_contact' => new ContactShortResource($this->me),
|
||||
'timezone' => $this->timezone,
|
||||
'currency' => new CurrencyResource($this->currency),
|
||||
'locale' => $this->locale,
|
||||
'is_policy_compliant' => $this->policy_compliant,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Http/Resources/Activity/Activity.php
Normal file
44
app/Http/Resources/Activity/Activity.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Activity;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Emotion\Emotion as EmotionResource;
|
||||
use App\Http\Resources\Activity\ActivityType as ActivityTypeResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Account\Activity>
|
||||
*/
|
||||
class Activity extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'activity',
|
||||
'summary' => $this->summary,
|
||||
'description' => $this->description,
|
||||
'happened_at' => DateHelper::getDate($this->happened_at),
|
||||
'activity_type' => new ActivityTypeResource($this->type),
|
||||
'attendees' => [
|
||||
'total' => $this->contacts()->count(),
|
||||
'contacts' => $this->getContactsForAPI(),
|
||||
],
|
||||
'emotions' => EmotionResource::collection($this->emotions),
|
||||
'url' => route('api.activity', $this->id),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Resources/Activity/ActivityType.php
Normal file
36
app/Http/Resources/Activity/ActivityType.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Activity;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Activity\ActivityTypeCategory as ActivityTypeCategoryResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Account\ActivityType>
|
||||
*/
|
||||
class ActivityType extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'activityType',
|
||||
'name' => $this->name,
|
||||
'location_type' => $this->location_type,
|
||||
'activity_type_category' => new ActivityTypeCategoryResource($this->category),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/Activity/ActivityTypeCategory.php
Normal file
33
app/Http/Resources/Activity/ActivityTypeCategory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Activity;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Account\ActivityTypeCategory>
|
||||
*/
|
||||
class ActivityTypeCategory extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'activityTypeCategory',
|
||||
'name' => $this->name,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Http/Resources/Address/Address.php
Normal file
44
app/Http/Resources/Address/Address.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Address;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Country\Country as CountryResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Address>
|
||||
*/
|
||||
class Address extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'address',
|
||||
'name' => $this->name,
|
||||
'street' => $this->place->street,
|
||||
'city' => $this->place->city,
|
||||
'province' => $this->place->province,
|
||||
'postal_code' => $this->place->postal_code,
|
||||
'latitude' => $this->place->latitude,
|
||||
'longitude' => $this->place->longitude,
|
||||
'country' => new CountryResource($this->place->country),
|
||||
'url' => route('api.address', $this->id),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/AuditLog/AuditLog.php
Normal file
38
app/Http/Resources/AuditLog/AuditLog.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\AuditLog;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use function Safe\json_decode;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Instance\AuditLog>
|
||||
*/
|
||||
class AuditLog extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'auditlog',
|
||||
'author' => ($this->author) ? [
|
||||
'id' => $this->author->id,
|
||||
'name' => $this->author->name,
|
||||
] : [
|
||||
'name' => $this->author_name,
|
||||
],
|
||||
'action' => $this->action,
|
||||
'objects' => json_decode($this->objects),
|
||||
'audited_at' => DateHelper::getTimestamp($this->audited_at),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/Call/Call.php
Normal file
40
app/Http/Resources/Call/Call.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Call;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Emotion\Emotion as EmotionResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Call>
|
||||
*/
|
||||
class Call extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'call',
|
||||
'called_at' => DateHelper::getTimestamp($this->called_at),
|
||||
'content' => $this->content,
|
||||
'contact_called' => $this->contact_called,
|
||||
'emotions' => EmotionResource::collection($this->emotions),
|
||||
'url' => route('api.call', $this->id),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Http/Resources/Company/Company.php
Normal file
34
app/Http/Resources/Company/Company.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Company;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Account\Company>
|
||||
*/
|
||||
class Company extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'company',
|
||||
'name' => $this->name,
|
||||
'website' => $this->website,
|
||||
'number_of_employees' => $this->number_of_employees,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Http/Resources/Contact/Contact.php
Normal file
24
app/Http/Resources/Contact/Contact.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Contact;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Contact>
|
||||
*/
|
||||
class Contact extends JsonResource
|
||||
{
|
||||
use ContactBase;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return $this->toArrayInternal($request, $request->input('with') == 'contactfields');
|
||||
}
|
||||
}
|
||||
126
app/Http/Resources/Contact/ContactBase.php
Normal file
126
app/Http/Resources/Contact/ContactBase.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Contact;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use App\Http\Resources\Tag\Tag as TagResource;
|
||||
use App\Http\Resources\Note\Note as NoteResource;
|
||||
use App\Http\Resources\Address\Address as AddressResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
use App\Http\Resources\ContactField\ContactField as ContactFieldResource;
|
||||
use App\Http\Resources\Relationship\RelationshipShort as RelationshipShortResource;
|
||||
|
||||
trait ContactBase
|
||||
{
|
||||
protected function toArrayInternal($request, $withContactField)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'contact',
|
||||
'hash_id' => $this->getHashId(),
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'nickname' => $this->nickname,
|
||||
'complete_name' => $this->name,
|
||||
'initials' => $this->getInitials(),
|
||||
'description' => $this->description,
|
||||
'gender' => is_null($this->gender) ? null : $this->gender->name,
|
||||
'gender_type' => is_null($this->gender) ? null : $this->gender->type,
|
||||
'is_starred' => (bool) $this->is_starred,
|
||||
'is_partial' => (bool) $this->is_partial,
|
||||
'is_active' => (bool) $this->is_active,
|
||||
'is_dead' => (bool) $this->is_dead,
|
||||
'is_me' => $this->isMe(),
|
||||
'last_called' => $this->when(! $this->is_partial, $this->last_talked_to),
|
||||
'last_activity_together' => $this->when(! $this->is_partial, $this->getLastActivityDate()),
|
||||
'stay_in_touch_frequency' => $this->when(! $this->is_partial, $this->stay_in_touch_frequency),
|
||||
'stay_in_touch_trigger_date' => $this->when(! $this->is_partial, DateHelper::getTimestamp($this->stay_in_touch_trigger_date)),
|
||||
'information' => [
|
||||
'relationships' => $this->when(! $this->is_partial, [
|
||||
'love' => [
|
||||
'total' => (is_null($this->getRelationshipsByRelationshipTypeGroup('love')) ? 0 : $this->getRelationshipsByRelationshipTypeGroup('love')->count()),
|
||||
'contacts' => (is_null($this->getRelationshipsByRelationshipTypeGroup('love')) ? null : RelationshipShortResource::collection($this->getRelationshipsByRelationshipTypeGroup('love'))),
|
||||
],
|
||||
'family' => [
|
||||
'total' => (is_null($this->getRelationshipsByRelationshipTypeGroup('family')) ? 0 : $this->getRelationshipsByRelationshipTypeGroup('family')->count()),
|
||||
'contacts' => (is_null($this->getRelationshipsByRelationshipTypeGroup('family')) ? null : RelationshipShortResource::collection($this->getRelationshipsByRelationshipTypeGroup('family'))),
|
||||
],
|
||||
'friend' => [
|
||||
'total' => (is_null($this->getRelationshipsByRelationshipTypeGroup('friend')) ? 0 : $this->getRelationshipsByRelationshipTypeGroup('friend')->count()),
|
||||
'contacts' => (is_null($this->getRelationshipsByRelationshipTypeGroup('friend')) ? null : RelationshipShortResource::collection($this->getRelationshipsByRelationshipTypeGroup('friend'))),
|
||||
],
|
||||
'work' => [
|
||||
'total' => (is_null($this->getRelationshipsByRelationshipTypeGroup('work')) ? 0 : $this->getRelationshipsByRelationshipTypeGroup('work')->count()),
|
||||
'contacts' => (is_null($this->getRelationshipsByRelationshipTypeGroup('work')) ? null : RelationshipShortResource::collection($this->getRelationshipsByRelationshipTypeGroup('work'))),
|
||||
],
|
||||
]),
|
||||
'dates' => [
|
||||
'birthdate' => [
|
||||
'is_age_based' => (is_null($this->birthdate) ? null : (bool) $this->birthdate->is_age_based),
|
||||
'is_year_unknown' => (is_null($this->birthdate) ? null : (bool) $this->birthdate->is_year_unknown),
|
||||
'date' => DateHelper::getTimestamp($this->birthdate),
|
||||
],
|
||||
'deceased_date' => [
|
||||
'is_age_based' => (is_null($this->deceasedDate) ? null : (bool) $this->deceasedDate->is_age_based),
|
||||
'is_year_unknown' => (is_null($this->deceasedDate) ? null : (bool) $this->deceasedDate->is_year_unknown),
|
||||
'date' => DateHelper::getTimestamp($this->deceasedDate),
|
||||
],
|
||||
],
|
||||
'career' => $this->when(! $this->is_partial, [
|
||||
'job' => $this->job,
|
||||
'company' => $this->company,
|
||||
]),
|
||||
'avatar' => $this->when(! $this->is_partial, [
|
||||
'url' => $this->getAvatarUrl(),
|
||||
'source' => $this->avatar_source,
|
||||
'default_avatar_color' => $this->default_avatar_color,
|
||||
]),
|
||||
'food_preferences' => $this->when(! $this->is_partial, $this->food_preferences),
|
||||
'how_you_met' => $this->when(! $this->is_partial, [
|
||||
'general_information' => $this->first_met_additional_info,
|
||||
'first_met_date' => [
|
||||
'is_age_based' => (is_null($this->firstMetDate) ? null : (bool) $this->firstMetDate->is_age_based),
|
||||
'is_year_unknown' => (is_null($this->firstMetDate) ? null : (bool) $this->firstMetDate->is_year_unknown),
|
||||
'date' => DateHelper::getTimestamp($this->firstMetDate),
|
||||
],
|
||||
'first_met_through_contact' => new ContactShortResource($this->getIntroducer()),
|
||||
]),
|
||||
],
|
||||
'addresses' => $this->when(! $this->is_partial, AddressResource::collection($this->addresses)),
|
||||
'tags' => $this->when(! $this->is_partial, TagResource::collection($this->tags)),
|
||||
'statistics' => $this->when(! $this->is_partial, [
|
||||
'number_of_calls' => $this->calls->count(),
|
||||
'number_of_notes' => $this->notes->count(),
|
||||
'number_of_activities' => $this->activities->count(),
|
||||
'number_of_reminders' => $this->reminders->count(),
|
||||
'number_of_tasks' => $this->tasks->count(),
|
||||
'number_of_gifts' => $this->gifts->count(),
|
||||
'number_of_debts' => $this->debts->count(),
|
||||
]),
|
||||
'contactFields' => $this->when($withContactField && ! $this->is_partial, ContactFieldResource::collection($this->contactFields)),
|
||||
'notes' => $this->when($withContactField && ! $this->is_partial, NoteResource::collection($this->notes()->latest()->limit(3)->get())),
|
||||
'url' => $this->when(! $this->is_partial, route('api.contact', $this->id)),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getHashId()
|
||||
{
|
||||
$hashid = '';
|
||||
if ($this->is_partial) {
|
||||
$realContact = $this->getRelatedRealContact();
|
||||
if ($realContact) {
|
||||
$hashid = $realContact->hashID();
|
||||
}
|
||||
} else {
|
||||
$hashid = $this->hashID();
|
||||
}
|
||||
|
||||
return $hashid;
|
||||
}
|
||||
}
|
||||
45
app/Http/Resources/Contact/ContactSearch.php
Normal file
45
app/Http/Resources/Contact/ContactSearch.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Contact;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Contact>
|
||||
*/
|
||||
class ContactSearch extends JsonResource
|
||||
{
|
||||
use ContactBase;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'contact',
|
||||
'route' => route('people.show', $this),
|
||||
'complete_name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'initials' => $this->getInitials(),
|
||||
'is_me' => $this->isMe(),
|
||||
'is_starred' => $this->is_starred,
|
||||
'information' => [
|
||||
'avatar' => [
|
||||
'url' => $this->getAvatarUrl(),
|
||||
'source' => $this->avatar_source,
|
||||
'default_avatar_color' => $this->default_avatar_color,
|
||||
],
|
||||
],
|
||||
'url' => $this->when(! $this->is_partial, route('api.contact', $this->id)),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
63
app/Http/Resources/Contact/ContactShort.php
Normal file
63
app/Http/Resources/Contact/ContactShort.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Contact;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Contact>
|
||||
*/
|
||||
class ContactShort extends JsonResource
|
||||
{
|
||||
use ContactBase;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'contact',
|
||||
'hash_id' => $this->getHashId(),
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'nickname' => $this->nickname,
|
||||
'complete_name' => $this->name,
|
||||
'initials' => $this->getInitials(),
|
||||
'gender' => is_null($this->gender) ? null : $this->gender->name,
|
||||
'gender_type' => is_null($this->gender) ? null : $this->gender->type,
|
||||
'is_starred' => (bool) $this->is_starred,
|
||||
'is_partial' => (bool) $this->is_partial,
|
||||
'is_active' => (bool) $this->is_active,
|
||||
'is_dead' => (bool) $this->is_dead,
|
||||
'is_me' => $this->isMe(),
|
||||
'information' => [
|
||||
'birthdate' => [
|
||||
'is_age_based' => (is_null($this->birthdate) ? null : (bool) $this->birthdate->is_age_based),
|
||||
'is_year_unknown' => (is_null($this->birthdate) ? null : (bool) $this->birthdate->is_year_unknown),
|
||||
'date' => DateHelper::getTimestamp($this->birthdate),
|
||||
],
|
||||
'deceased_date' => [
|
||||
'is_age_based' => (is_null($this->deceasedDate) ? null : (bool) $this->deceasedDate->is_age_based),
|
||||
'is_year_unknown' => (is_null($this->deceasedDate) ? null : (bool) $this->deceasedDate->is_year_unknown),
|
||||
'date' => DateHelper::getTimestamp($this->deceasedDate),
|
||||
],
|
||||
'avatar' => [
|
||||
'url' => $this->getAvatarUrl(),
|
||||
'source' => $this->avatar_source,
|
||||
'default_avatar_color' => $this->default_avatar_color,
|
||||
],
|
||||
],
|
||||
'url' => $this->when(! $this->is_partial, route('api.contact', $this->id)),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Http/Resources/Contact/ContactWithContactFields.php
Normal file
24
app/Http/Resources/Contact/ContactWithContactFields.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Contact;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Contact>
|
||||
*/
|
||||
class ContactWithContactFields extends JsonResource
|
||||
{
|
||||
use ContactBase;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return $this->toArrayInternal($request, true);
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/ContactField/ContactField.php
Normal file
38
app/Http/Resources/ContactField/ContactField.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\ContactField;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
use App\Http\Resources\Settings\ContactFieldType\ContactFieldType as ContactFieldTypeResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\ContactField>
|
||||
*/
|
||||
class ContactField extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'contactfield',
|
||||
'content' => $this->data,
|
||||
'contact_field_type' => new ContactFieldTypeResource($this->contactFieldType),
|
||||
'labels' => ContactFieldLabel::collection($this->labels),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/ContactField/ContactFieldLabel.php
Normal file
33
app/Http/Resources/ContactField/ContactFieldLabel.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\ContactField;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\ContactFieldLabel>
|
||||
*/
|
||||
class ContactFieldLabel extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'contactfieldlabel',
|
||||
'type' => $this->label_i18n ?: $this->label,
|
||||
'label' => $this->label_i18n ? trans('people.contact_field_label_'.$this->label_i18n) : $this->label,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/Conversation/Conversation.php
Normal file
40
app/Http/Resources/Conversation/Conversation.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Conversation;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Conversation\Message as MessageResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
use App\Http\Resources\Settings\ContactFieldType\ContactFieldType as ContactFieldTypeResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Conversation>
|
||||
*/
|
||||
class Conversation extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'conversation',
|
||||
'happened_at' => DateHelper::getTimestamp($this->happened_at),
|
||||
'messages' => MessageResource::collection($this->messages),
|
||||
'contact_field_type' => new ContactFieldTypeResource($this->contactFieldType),
|
||||
'url' => route('api.conversation', $this->id),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/Conversation/Message.php
Normal file
40
app/Http/Resources/Conversation/Message.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Conversation;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Message>
|
||||
*/
|
||||
class Message extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'message',
|
||||
'content' => $this->content,
|
||||
'written_at' => DateHelper::getTimestamp($this->written_at),
|
||||
'written_by_me' => (bool) $this->written_by_me,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'conversation' => [
|
||||
'id' => $this->conversation->id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/Country/Country.php
Normal file
33
app/Http/Resources/Country/Country.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Country;
|
||||
|
||||
use App\Helpers\CountriesHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class Country extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
if (is_array($this->resource)) {
|
||||
$id = $this->resource['id'];
|
||||
$name = $this->resource['country'];
|
||||
} else {
|
||||
$id = $this->resource;
|
||||
$name = CountriesHelper::get($this->resource);
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $id,
|
||||
'object' => 'country',
|
||||
'name' => $name,
|
||||
'iso' => $id,
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/Debt/Debt.php
Normal file
40
app/Http/Resources/Debt/Debt.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Debt;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Debt>
|
||||
*/
|
||||
class Debt extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'debt',
|
||||
'in_debt' => $this->in_debt,
|
||||
'status' => $this->status,
|
||||
'amount' => $this->amount,
|
||||
'value' => $this->value,
|
||||
'amount_with_currency' => $this->displayValue,
|
||||
'reason' => $this->reason,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
42
app/Http/Resources/Document/Document.php
Normal file
42
app/Http/Resources/Document/Document.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Document;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Document>
|
||||
*/
|
||||
class Document extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'document',
|
||||
'original_filename' => $this->original_filename,
|
||||
'new_filename' => $this->new_filename,
|
||||
'filesize' => $this->filesize,
|
||||
'type' => $this->type,
|
||||
'mime_type' => $this->mime_type,
|
||||
'number_of_downloads' => $this->number_of_downloads,
|
||||
'link' => $this->getDownloadLink(),
|
||||
'url' => route('api.document', $this->id),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Http/Resources/Emotion/Emotion.php
Normal file
26
app/Http/Resources/Emotion/Emotion.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Emotion;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Instance\Emotion\Emotion>
|
||||
*/
|
||||
class Emotion extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'emotion',
|
||||
'name' => $this->name,
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/Gender/Gender.php
Normal file
33
app/Http/Resources/Gender/Gender.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Gender;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Gender>
|
||||
*/
|
||||
class Gender extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'gender',
|
||||
'name' => $this->name,
|
||||
'type' => $this->type,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
45
app/Http/Resources/Gift/Gift.php
Normal file
45
app/Http/Resources/Gift/Gift.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Gift;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Photo\Photo as PhotoResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Gift>
|
||||
*/
|
||||
class Gift extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'gift',
|
||||
'name' => $this->name,
|
||||
'comment' => $this->comment,
|
||||
'url' => $this->url,
|
||||
'amount' => $this->amount,
|
||||
'value' => $this->value,
|
||||
'amount_with_currency' => $this->displayValue,
|
||||
'status' => $this->status,
|
||||
'date' => DateHelper::getDate($this->date),
|
||||
'recipient' => new ContactShortResource($this->recipient),
|
||||
'photos' => PhotoResource::collection($this->photos),
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Resources/Journal/Entry.php
Normal file
36
app/Http/Resources/Journal/Entry.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Journal;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Journal\Entry>
|
||||
*/
|
||||
class Entry extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'entry',
|
||||
'title' => $this->title,
|
||||
'post' => $this->post,
|
||||
'date' => $this->date,
|
||||
'url' => route('api.entry', $this->id),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/Http/Resources/LifeEvent/LifeEvent.php
Normal file
39
app/Http/Resources/LifeEvent/LifeEvent.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\LifeEvent;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
use App\Http\Resources\LifeEvent\LifeEventType as LifeEventTypeResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\LifeEvent>
|
||||
*/
|
||||
class LifeEvent extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'lifeevent',
|
||||
'name' => $this->name,
|
||||
'note' => $this->note,
|
||||
'happened_at' => DateHelper::getTimestamp($this->happened_at),
|
||||
'life_event_type' => new LifeEventTypeResource($this->lifeEventType),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/LifeEvent/LifeEventCategory.php
Normal file
35
app/Http/Resources/LifeEvent/LifeEventCategory.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\LifeEvent;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\LifeEventCategory>
|
||||
*/
|
||||
class LifeEventCategory extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'lifeeventcategory',
|
||||
'name' => $this->name,
|
||||
'core_monica_data' => (bool) $this->core_monica_data,
|
||||
'default_life_event_category_key' => $this->default_life_event_category_key,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/LifeEvent/LifeEventType.php
Normal file
37
app/Http/Resources/LifeEvent/LifeEventType.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\LifeEvent;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\LifeEvent\LifeEventCategory as LifeEventCategoryResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\LifeEventType>
|
||||
*/
|
||||
class LifeEventType extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'lifeeventtype',
|
||||
'name' => $this->name,
|
||||
'core_monica_data' => (bool) $this->core_monica_data,
|
||||
'default_life_event_type_key' => $this->default_life_event_type_key,
|
||||
'life_event_category' => new LifeEventCategoryResource($this->lifeEventCategory),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/Note/Note.php
Normal file
38
app/Http/Resources/Note/Note.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Note;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Note>
|
||||
*/
|
||||
class Note extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'note',
|
||||
'body' => $this->body,
|
||||
'is_favorited' => (bool) $this->is_favorited,
|
||||
'favorited_at' => DateHelper::getTimestamp($this->favorited_at),
|
||||
'url' => route('api.note', $this->id),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
42
app/Http/Resources/Occupation/Occupation.php
Normal file
42
app/Http/Resources/Occupation/Occupation.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Occupation;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Company\Company as CompanyResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Occupation>
|
||||
*/
|
||||
class Occupation extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'occupation',
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'salary' => $this->salary,
|
||||
'salary_unit' => $this->salary_unit,
|
||||
'currently_works_here' => (bool) $this->currently_works_here,
|
||||
'start_date' => DateHelper::getDate($this->start_date),
|
||||
'end_date' => DateHelper::getDate($this->end_date),
|
||||
'company' => new CompanyResource($this->company),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Resources/Pet/Pet.php
Normal file
36
app/Http/Resources/Pet/Pet.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Pet;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Pet>
|
||||
*/
|
||||
class Pet extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'pet',
|
||||
'name' => $this->name,
|
||||
'pet_category' => PetCategory::make($this->petCategory),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Http/Resources/Pet/PetCategory.php
Normal file
27
app/Http/Resources/Pet/PetCategory.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Pet;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\PetCategory>
|
||||
*/
|
||||
class PetCategory extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'pet_category',
|
||||
'name' => $this->name,
|
||||
'is_common' => (bool) $this->is_common,
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/Photo/Photo.php
Normal file
40
app/Http/Resources/Photo/Photo.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Photo;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Account\Photo>
|
||||
*/
|
||||
class Photo extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'photo',
|
||||
'original_filename' => $this->original_filename,
|
||||
'new_filename' => $this->new_filename,
|
||||
'filesize' => $this->filesize,
|
||||
'mime_type' => $this->mime_type,
|
||||
'dataUrl' => $this->dataUrl(),
|
||||
'link' => $this->url(),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact()),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/Http/Resources/Place/Place.php
Normal file
39
app/Http/Resources/Place/Place.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Place;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Country\Country as CountryResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Account\Place>
|
||||
*/
|
||||
class Place extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'place',
|
||||
'street' => $this->street,
|
||||
'city' => $this->city,
|
||||
'province' => $this->province,
|
||||
'postal_code' => $this->postal_code,
|
||||
'latitude' => $this->latitude,
|
||||
'longitude' => $this->longitude,
|
||||
'country' => new CountryResource($this->country),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/Relationship/Relationship.php
Normal file
38
app/Http/Resources/Relationship/Relationship.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Relationship;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
use App\Http\Resources\RelationshipType\RelationshipType as RelationshipTypeResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Relationship\Relationship>
|
||||
*/
|
||||
class Relationship extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'relationship',
|
||||
'contact_is' => new ContactShortResource($this->contactIs),
|
||||
'relationship_type' => new RelationshipTypeResource($this->relationshipType),
|
||||
'of_contact' => new ContactShortResource($this->ofContact),
|
||||
'url' => route('api.relationship', $this->id),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/Relationship/RelationshipShort.php
Normal file
30
app/Http/Resources/Relationship/RelationshipShort.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Relationship;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Relationship\Relationship>
|
||||
*/
|
||||
class RelationshipShort extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'relationship' => [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'name' => $this->relationshipType->name,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->ofContact),
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/RelationshipType/RelationshipType.php
Normal file
35
app/Http/Resources/RelationshipType/RelationshipType.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\RelationshipType;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Relationship\RelationshipType>
|
||||
*/
|
||||
class RelationshipType extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'relationshiptype',
|
||||
'name' => $this->name,
|
||||
'name_reverse_relationship' => $this->name_reverse_relationship,
|
||||
'relationship_type_group_id' => $this->relationship_type_group_id,
|
||||
'delible' => $this->delible,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\RelationshipTypeGroup;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Relationship\RelationshipTypeGroup>
|
||||
*/
|
||||
class RelationshipTypeGroup extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'relationshiptypegroup',
|
||||
'name' => $this->name,
|
||||
'delible' => (bool) $this->delible,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Resources/Reminder/Reminder.php
Normal file
40
app/Http/Resources/Reminder/Reminder.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Reminder;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Reminder>
|
||||
*/
|
||||
class Reminder extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'reminder',
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'frequency_type' => $this->frequency_type,
|
||||
'frequency_number' => $this->frequency_number,
|
||||
'initial_date' => DateHelper::getTimestamp($this->initial_date),
|
||||
'delible' => (bool) $this->delible,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
41
app/Http/Resources/Reminder/ReminderOutbox.php
Normal file
41
app/Http/Resources/Reminder/ReminderOutbox.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Reminder;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\ReminderOutbox>
|
||||
*/
|
||||
class ReminderOutbox extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'reminder_id' => $this->reminder_id,
|
||||
'object' => $this->nature,
|
||||
'planned_date' => $this->planned_date,
|
||||
'title' => $this->reminder->title,
|
||||
'description' => $this->reminder->description,
|
||||
'frequency_type' => $this->reminder->frequency_type,
|
||||
'frequency_number' => $this->reminder->frequency_number,
|
||||
'initial_date' => DateHelper::getTimestamp($this->reminder->initial_date),
|
||||
'delible' => (bool) $this->reminder->delible,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->reminder->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Resources/Settings/Compliance/Compliance.php
Normal file
32
app/Http/Resources/Settings/Compliance/Compliance.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Settings\Compliance;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Settings\Term>
|
||||
*/
|
||||
class Compliance extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'term',
|
||||
'term_version' => $this->term_version,
|
||||
'term_content' => $this->term_content,
|
||||
'privacy_version' => $this->privacy_version,
|
||||
'privacy_content' => $this->privacy_content,
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Settings\ContactFieldType;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\ContactFieldType>
|
||||
*/
|
||||
class ContactFieldType extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'contactfieldtype',
|
||||
'name' => $this->name,
|
||||
'fontawesome_icon' => $this->fontawesome_icon,
|
||||
'protocol' => $this->protocol,
|
||||
'delible' => (bool) $this->delible,
|
||||
'type' => $this->type,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Resources/Settings/Currency/Currency.php
Normal file
28
app/Http/Resources/Settings/Currency/Currency.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Settings\Currency;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Settings\Currency>
|
||||
*/
|
||||
class Currency extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'currency',
|
||||
'iso' => $this->iso,
|
||||
'name' => $this->name,
|
||||
'symbol' => $this->symbol,
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/Settings/WebauthnKey/WebauthnKey.php
Normal file
30
app/Http/Resources/Settings/WebauthnKey/WebauthnKey.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Settings\WebauthnKey;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\LaravelWebauthn\Models\WebauthnKey>
|
||||
*/
|
||||
class WebauthnKey extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'webauthnKey',
|
||||
'name' => $this->name,
|
||||
'counter' => $this->counter,
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/Tag/Tag.php
Normal file
33
app/Http/Resources/Tag/Tag.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Tag;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Tag>
|
||||
*/
|
||||
class Tag extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'object' => 'tag',
|
||||
'name' => $this->name,
|
||||
'name_slug' => $this->name_slug,
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/Task/Task.php
Normal file
38
app/Http/Resources/Task/Task.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Task;
|
||||
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\Contact\ContactShort as ContactShortResource;
|
||||
|
||||
/**
|
||||
* @extends JsonResource<\App\Models\Contact\Task>
|
||||
*/
|
||||
class Task extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'object' => 'task',
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'completed' => (bool) $this->completed,
|
||||
'completed_at' => DateHelper::getTimestamp($this->completed_at),
|
||||
'account' => [
|
||||
'id' => $this->account_id,
|
||||
],
|
||||
'contact' => new ContactShortResource($this->contact),
|
||||
'created_at' => DateHelper::getTimestamp($this->created_at),
|
||||
'updated_at' => DateHelper::getTimestamp($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user