refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

View 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),
],
];
}
}

View 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,
];
}),
],
];
}
}

View 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,
];
}),
],
];
}
}

View 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',
];
}

View 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(),
];
}
}

View 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),
];
}),
],
];
}
}

View 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,
],
];
}
}

View 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,
];
}),
],
];
}
}

View 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(),
],
];
}
}

View 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',
];
}