-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export data as json format (#4779)
- Loading branch information
Showing
126 changed files
with
2,786 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
]; | ||
}), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
]; | ||
}), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
]; | ||
}), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
]; | ||
}), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
], | ||
]; | ||
} | ||
} |
Oops, something went wrong.