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:
63
app/ExportResources/Account/Account.php
Normal file
63
app/ExportResources/Account/Account.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\Models\Contact\Gender;
|
||||
use App\ExportResources\User\User;
|
||||
use App\ExportResources\User\Module;
|
||||
use App\ExportResources\ExportResource;
|
||||
use App\ExportResources\Contact\Contact;
|
||||
use App\ExportResources\Contact\Document;
|
||||
use App\ExportResources\Instance\AuditLog;
|
||||
use App\ExportResources\Journal\JournalEntry;
|
||||
use App\ExportResources\Contact\ContactFieldType;
|
||||
use App\ExportResources\Relationship\Relationship;
|
||||
use App\ExportResources\Contact\Gender as GenderResource;
|
||||
|
||||
class Account extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'number_of_invitations_sent',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
User::countCollection($this->users),
|
||||
Contact::countCollection($this->allContacts),
|
||||
Relationship::countCollection($this->relationships),
|
||||
Addressbook::countCollection($this->addressBooks),
|
||||
AddressbookSubscription::countCollection($this->addressBookSubscriptions),
|
||||
Photo::countCollection($this->photos),
|
||||
Document::countCollection($this->documents),
|
||||
Activity::countCollection($this->activities),
|
||||
],
|
||||
'properties' => [
|
||||
'default_gender' => $this->when($this->default_gender_id !== null, function () {
|
||||
$defaultGender = Gender::where(['account_id' => $this->id])->find($this->default_gender_id);
|
||||
|
||||
return $defaultGender->uuid;
|
||||
}),
|
||||
'journal_entries' => JournalEntry::collection($this->journalEntries()->entry()->get()),
|
||||
'modules' => Module::collection($this->modules),
|
||||
'reminder_rules' => ReminderRule::collection($this->reminderRules),
|
||||
'audit_logs' => AuditLog::collection($this->auditLogs),
|
||||
],
|
||||
'instance' => [
|
||||
'activity_types' => ActivityType::collection($this->activityTypes),
|
||||
'activity_type_categories' => ActivityTypeCategory::collection($this->activityTypeCategories),
|
||||
'contact_field_types' => ContactFieldType::collection($this->contactFieldTypes),
|
||||
'genders' => GenderResource::collection($this->genders),
|
||||
'life_event_types' => LifeEventType::collection($this->lifeEventTypes),
|
||||
'life_event_categories' => LifeEventCategory::collection($this->lifeEventCategories),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/ExportResources/Account/Activity.php
Normal file
33
app/ExportResources/Account/Activity.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Activity extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'summary',
|
||||
'description',
|
||||
'happened_at',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
$this->mergeWhen($this->type !== null, function () {
|
||||
return [
|
||||
'type' => $this->type->uuid,
|
||||
];
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/ExportResources/Account/ActivityType.php
Normal file
33
app/ExportResources/Account/ActivityType.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class ActivityType extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'translation_key',
|
||||
'name',
|
||||
'location_type',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
$this->mergeWhen($this->category !== null, function () {
|
||||
return [
|
||||
'category' => $this->category->uuid,
|
||||
];
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/ExportResources/Account/ActivityTypeCategory.php
Normal file
19
app/ExportResources/Account/ActivityTypeCategory.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class ActivityTypeCategory extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'translation_key',
|
||||
'name',
|
||||
];
|
||||
}
|
||||
27
app/ExportResources/Account/Addressbook.php
Normal file
27
app/ExportResources/Account/Addressbook.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Addressbook extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'name',
|
||||
'description',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'user' => $this->user->uuid,
|
||||
'contacts' => $this->contacts->mapUuid(),
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/ExportResources/Account/AddressbookSubscription.php
Normal file
44
app/ExportResources/Account/AddressbookSubscription.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\Models\User\SyncToken;
|
||||
use App\ExportResources\ExportResource;
|
||||
use App\ExportResources\User\SyncToken as SyncTokenResource;
|
||||
|
||||
class AddressbookSubscription extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'name',
|
||||
'uri',
|
||||
'username',
|
||||
'readonly',
|
||||
'active',
|
||||
'capabilities',
|
||||
'frequency',
|
||||
'last_syncronized_at',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
'addressbook' => $this->addressBook->uuid,
|
||||
'sync_token' => $this->syncToken,
|
||||
$this->merge(function () {
|
||||
$localSyncToken = SyncToken::where('account_id', $this->account_id)->find($this->localSyncToken);
|
||||
|
||||
return [
|
||||
'local_sync_token' => new SyncTokenResource($localSyncToken),
|
||||
];
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/ExportResources/Account/LifeEventCategory.php
Normal file
27
app/ExportResources/Account/LifeEventCategory.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class LifeEventCategory extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'core_monica_data',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
'translation_key' => $this->default_life_event_category_key,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/ExportResources/Account/LifeEventType.php
Normal file
34
app/ExportResources/Account/LifeEventType.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class LifeEventType extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'name',
|
||||
'core_monica_data',
|
||||
'specific_information_structure',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
'translation_key' => $this->default_life_event_type_key,
|
||||
$this->mergeWhen($this->lifeEventCategory !== null, function () {
|
||||
return [
|
||||
'category' => $this->lifeEventCategory->uuid,
|
||||
];
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/ExportResources/Account/Photo.php
Normal file
29
app/ExportResources/Account/Photo.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class Photo extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'uuid',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'original_filename',
|
||||
'filesize',
|
||||
'mime_type',
|
||||
];
|
||||
|
||||
public function data(): ?array
|
||||
{
|
||||
return [
|
||||
'properties' => [
|
||||
'dataUrl' => $this->dataUrl(),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
18
app/ExportResources/Account/ReminderRule.php
Normal file
18
app/ExportResources/Account/ReminderRule.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\ExportResources\Account;
|
||||
|
||||
use App\ExportResources\ExportResource;
|
||||
|
||||
class ReminderRule extends ExportResource
|
||||
{
|
||||
protected $columns = [
|
||||
'number_of_days_before',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $properties = [
|
||||
'active',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user