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:
33
app/ExportResources/Contact/Address.php
Normal file
33
app/ExportResources/Contact/Address.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Address extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'name',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
'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' => $this->place->country,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/ExportResources/Contact/Call.php
Normal file
33
app/ExportResources/Contact/Call.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Call extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'called_at',
|
||||
'content',
|
||||
'contact_called',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
$this->mergeWhen($this->emotions->count() > 0, [
|
||||
'emotions' => $this->emotions->map(function ($emotion) {
|
||||
return $emotion->name;
|
||||
})->toArray(),
|
||||
]),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
106
app/ExportResources/Contact/Contact.php
Normal file
106
app/ExportResources/Contact/Contact.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\Account\Photo;
|
||||
use App\ExportResources\ExportResource;
|
||||
use App\ExportResources\Account\Activity;
|
||||
use App\ExportResources\Instance\SpecialDate;
|
||||
use App\Models\Contact\Reminder as ContactReminder;
|
||||
|
||||
class Contact extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'first_name',
|
||||
'middle_name',
|
||||
'last_name',
|
||||
'nickname',
|
||||
'description',
|
||||
'is_starred',
|
||||
'is_partial',
|
||||
'is_active',
|
||||
'is_dead',
|
||||
'job',
|
||||
'company',
|
||||
'food_preferences',
|
||||
'last_talked_to',
|
||||
'last_consulted_at',
|
||||
'number_of_views',
|
||||
'stay_in_touch_frequency',
|
||||
'stay_in_touch_trigger_date',
|
||||
'vcard',
|
||||
'distant_etag',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
'avatar' => [
|
||||
'avatar_source' => $this->avatar_source,
|
||||
'avatar_gravatar_url' => $this->avatar_gravatar_url,
|
||||
'avatar_adorable_uuid' => $this->avatar_adorable_uuid,
|
||||
'avatar_default_url' => $this->avatar_default_url,
|
||||
$this->mergeWhen($this->avatarPhoto !== null, function () {
|
||||
return ['avatar_photo' => $this->avatarPhoto->uuid];
|
||||
}),
|
||||
'has_avatar' => $this->has_avatar,
|
||||
'avatar_external_url' => $this->avatar_external_url,
|
||||
'avatar_file_name' => $this->avatar_file_name,
|
||||
'avatar_location' => $this->avatar_location,
|
||||
'gravatar_url' => $this->gravatar_url,
|
||||
'default_avatar_color' => $this->default_avatar_color,
|
||||
],
|
||||
'tags' => $this->when($this->tags->count() > 0, function () {
|
||||
return $this->tags->map(function ($tag) {
|
||||
return $tag->name;
|
||||
})->toArray();
|
||||
}),
|
||||
$this->mergeWhen($this->gender !== null, function () {
|
||||
return ['gender' => $this->gender->uuid];
|
||||
}),
|
||||
$this->mergeWhen($this->birthdate, [
|
||||
'birthdate' => new SpecialDate($this->birthdate),
|
||||
]),
|
||||
$this->mergeWhen($this->deceasedDate, [
|
||||
'deceased_date' => new SpecialDate($this->deceasedDate),
|
||||
]),
|
||||
$this->mergeWhen($this->deceased_reminder_id, function () {
|
||||
return ['deceased_reminder' => new Reminder(ContactReminder::find($this->deceased_reminder_id))];
|
||||
}),
|
||||
$this->mergeWhen($this->firstMetDate, [
|
||||
'first_met_date' => new SpecialDate($this->firstMetDate),
|
||||
]),
|
||||
$this->mergeWhen($this->getIntroducer() !== null, function () {
|
||||
return ['first_met_through' => $this->getIntroducer()->uuid];
|
||||
}),
|
||||
$this->mergeWhen($this->first_met_reminder_id !== null, function () {
|
||||
return ['first_met_reminder' => new Reminder(ContactReminder::find($this->first_met_reminder_id))];
|
||||
}),
|
||||
],
|
||||
'data' => [
|
||||
Call::countCollection($this->calls),
|
||||
ContactField::countCollection($this->contactFields),
|
||||
Debt::countCollection($this->debts),
|
||||
Gift::countCollection($this->gifts),
|
||||
Note::countCollection($this->notes),
|
||||
Reminder::countCollection($this->reminders),
|
||||
Task::countCollection($this->tasks),
|
||||
Address::countCollection($this->addresses),
|
||||
Pet::countCollection($this->pets),
|
||||
Conversation::countCollection($this->conversations),
|
||||
LifeEvent::countCollection($this->lifeEvents),
|
||||
Activity::uuidCollection($this->activities),
|
||||
Photo::uuidCollection($this->photos),
|
||||
Document::uuidCollection($this->documents),
|
||||
// Occupation::collection($this->occupations),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/ExportResources/Contact/ContactField.php
Normal file
29
app/ExportResources/Contact/ContactField.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class ContactField extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'data',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
$this->mergeWhen($this->contactFieldType !== null, function () {
|
||||
return ['type' => $this->contactFieldType->uuid];
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
22
app/ExportResources/Contact/ContactFieldType.php
Normal file
22
app/ExportResources/Contact/ContactFieldType.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class ContactFieldType extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'name',
|
||||
'fontawesome_icon',
|
||||
'protocol',
|
||||
'delible',
|
||||
'type',
|
||||
];
|
||||
}
|
||||
30
app/ExportResources/Contact/Conversation.php
Normal file
30
app/ExportResources/Contact/Conversation.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Conversation extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'happened_at',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
$this->mergeWhen($this->contactFieldType !== null, function () {
|
||||
return ['contact_field_type' => $this->contactFieldType->uuid];
|
||||
}),
|
||||
'messages' => Message::collection($this->messages),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/ExportResources/Contact/Debt.php
Normal file
29
app/ExportResources/Contact/Debt.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Debt extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'amount',
|
||||
'currency',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
'in_debt' => $this->in_debt === 'yes',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/ExportResources/Contact/Document.php
Normal file
33
app/ExportResources/Contact/Document.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Document extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'original_filename',
|
||||
'filesize',
|
||||
'type',
|
||||
'mime_type',
|
||||
'number_of_downloads',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
$this->mergeWhen(($dataUrl = $this->dataUrl()) !== null, [
|
||||
'dataUrl' => $dataUrl,
|
||||
]),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/ExportResources/Contact/Gender.php
Normal file
19
app/ExportResources/Contact/Gender.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Gender extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'name',
|
||||
'type',
|
||||
];
|
||||
}
|
||||
37
app/ExportResources/Contact/Gift.php
Normal file
37
app/ExportResources/Contact/Gift.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Gift extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'name',
|
||||
'comment',
|
||||
'url',
|
||||
'amount',
|
||||
'status',
|
||||
'date',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
$this->mergeWhen($this->recipient !== null, function () {
|
||||
return ['recipient' => $this->recipient->uuid];
|
||||
}),
|
||||
$this->mergeWhen($this->photos->count() > 0, [
|
||||
'photos' => $this->photos->mapUuid(),
|
||||
]),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/ExportResources/Contact/LifeEvent.php
Normal file
32
app/ExportResources/Contact/LifeEvent.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class LifeEvent extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'name',
|
||||
'note',
|
||||
'happened_at',
|
||||
'specific_information',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
$this->mergeWhen($this->lifeEventType != null, function () {
|
||||
return ['type' => $this->lifeEventType->uuid];
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
20
app/ExportResources/Contact/Message.php
Normal file
20
app/ExportResources/Contact/Message.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Message extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'content',
|
||||
'written_at',
|
||||
'written_by_me',
|
||||
];
|
||||
}
|
||||
20
app/ExportResources/Contact/Note.php
Normal file
20
app/ExportResources/Contact/Note.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Note extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'body',
|
||||
'is_favorite',
|
||||
'favorited_at',
|
||||
];
|
||||
}
|
||||
29
app/ExportResources/Contact/Pet.php
Normal file
29
app/ExportResources/Contact/Pet.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Pet extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'name',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
$this->mergeWhen($this->petCategory !== null, function () {
|
||||
return ['category' => $this->petCategory->name];
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/ExportResources/Contact/Reminder.php
Normal file
24
app/ExportResources/Contact/Reminder.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Reminder extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'initial_date',
|
||||
'title',
|
||||
'description',
|
||||
'frequency_type',
|
||||
'frequency_number',
|
||||
'delible',
|
||||
'inactive',
|
||||
];
|
||||
}
|
||||
21
app/ExportResources/Contact/Task.php
Normal file
21
app/ExportResources/Contact/Task.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Contact;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Task extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'title',
|
||||
'description',
|
||||
'completed',
|
||||
'completed_at',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user