diff --git a/app/Jobs/SetupAccount.php b/app/Jobs/SetupAccount.php
index 67315298fe1..dc52aeb05e7 100644
--- a/app/Jobs/SetupAccount.php
+++ b/app/Jobs/SetupAccount.php
@@ -86,6 +86,7 @@ public function handle()
$this->addTemplate();
$this->addTemplatePageContactInformation();
$this->addTemplatePageFeed();
+ $this->addTemplatePageContact();
$this->addTemplatePageSocial();
$this->addTemplatePageLifeEvents();
$this->addTemplatePageInformation();
@@ -287,6 +288,49 @@ private function addTemplatePageFeed(): void
]);
}
+ private function addTemplatePageContact(): void
+ {
+ $template = (new CreateTemplatePage())->execute([
+ 'account_id' => $this->user->account_id,
+ 'author_id' => $this->user->id,
+ 'template_id' => $this->template->id,
+ 'name' => trans('app.default_template_page_contact'),
+ 'can_be_deleted' => true,
+ ]);
+
+ // Addresses
+ $module = (new CreateModule())->execute([
+ 'account_id' => $this->user->account_id,
+ 'author_id' => $this->user->id,
+ 'name' => trans('app.module_addresses'),
+ 'type' => Module::TYPE_ADDRESSES,
+ 'can_be_deleted' => false,
+ ]);
+ (new AssociateModuleToTemplatePage())->execute([
+ 'account_id' => $this->user->account_id,
+ 'author_id' => $this->user->id,
+ 'template_id' => $this->template->id,
+ 'template_page_id' => $template->id,
+ 'module_id' => $module->id,
+ ]);
+
+ // Contact information
+ $module = (new CreateModule())->execute([
+ 'account_id' => $this->user->account_id,
+ 'author_id' => $this->user->id,
+ 'name' => trans('app.module_contact_information'),
+ 'type' => Module::TYPE_CONTACT_INFORMATION,
+ 'can_be_deleted' => false,
+ ]);
+ (new AssociateModuleToTemplatePage())->execute([
+ 'account_id' => $this->user->account_id,
+ 'author_id' => $this->user->id,
+ 'template_id' => $this->template->id,
+ 'template_page_id' => $template->id,
+ 'module_id' => $module->id,
+ ]);
+ }
+
private function addTemplatePageSocial(): void
{
$templatePageSocial = (new CreateTemplatePage())->execute([
@@ -383,22 +427,6 @@ private function addTemplatePageInformation(): void
'can_be_deleted' => true,
]);
- // Addresses
- $module = (new CreateModule())->execute([
- 'account_id' => $this->user->account_id,
- 'author_id' => $this->user->id,
- 'name' => trans('app.module_addresses'),
- 'type' => Module::TYPE_ADDRESSES,
- 'can_be_deleted' => false,
- ]);
- (new AssociateModuleToTemplatePage())->execute([
- 'account_id' => $this->user->account_id,
- 'author_id' => $this->user->id,
- 'template_id' => $this->template->id,
- 'template_page_id' => $templatePageInformation->id,
- 'module_id' => $module->id,
- ]);
-
// Notes
$module = (new CreateModule())->execute([
'account_id' => $this->user->account_id,
diff --git a/app/Models/ContactInformation.php b/app/Models/ContactInformation.php
index 9de7e390e7d..5c57313b9cb 100644
--- a/app/Models/ContactInformation.php
+++ b/app/Models/ContactInformation.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -42,4 +43,26 @@ public function contactInformationType(): BelongsTo
{
return $this->belongsTo(ContactInformationType::class, 'type_id');
}
+
+ /**
+ * Get the content of the contact information.
+ * If the contact information type is a phone number or an email, return the
+ * content. If it's something else, return the contact information type's label.
+ *
+ * @return Attribute
+ */
+ protected function name(): Attribute
+ {
+ return Attribute::make(
+ get: function ($value) {
+ $type = $this->contactInformationType;
+
+ if (! $type->can_be_deleted) {
+ return $this->data;
+ } else {
+ return $type->name;
+ }
+ }
+ );
+ }
}
diff --git a/app/Models/Module.php b/app/Models/Module.php
index 9b2ac223636..666ff93a00f 100644
--- a/app/Models/Module.php
+++ b/app/Models/Module.php
@@ -33,6 +33,7 @@ class Module extends Model
public const TYPE_GOALS = 'goals';
public const TYPE_ADDRESSES = 'addresses';
public const TYPE_GROUPS = 'groups';
+ public const TYPE_CONTACT_INFORMATION = 'contact_information';
/**
* The attributes that are mass assignable.
diff --git a/domains/Contact/ManageContact/Services/CopyContactToAnotherVault.php b/domains/Contact/ManageContact/Services/CopyContactToAnotherVault.php
index 3497784d443..ca7424445ce 100644
--- a/domains/Contact/ManageContact/Services/CopyContactToAnotherVault.php
+++ b/domains/Contact/ManageContact/Services/CopyContactToAnotherVault.php
@@ -9,6 +9,7 @@
use App\Models\Contact;
use App\Models\Vault;
use App\Services\BaseService;
+use Carbon\Carbon;
class CopyContactToAnotherVault extends BaseService implements ServiceInterface
{
@@ -58,6 +59,7 @@ public function execute(array $data): Contact
$this->data = $data;
$this->validate();
$this->copy();
+ $this->updateLastEditedDate();
$this->log();
return $this->newContact;
@@ -89,6 +91,12 @@ private function copy(): void
$this->newContact->save();
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function log(): void
{
CreateAuditLog::dispatch([
diff --git a/domains/Contact/ManageContact/Services/CreateContact.php b/domains/Contact/ManageContact/Services/CreateContact.php
index 36e6d07e58c..e2bbedaac82 100644
--- a/domains/Contact/ManageContact/Services/CreateContact.php
+++ b/domains/Contact/ManageContact/Services/CreateContact.php
@@ -67,6 +67,7 @@ public function execute(array $data): Contact
$this->validate();
$this->createContact();
$this->generateAvatar();
+ $this->updateLastEditedDate();
$this->log();
return $this->contact;
@@ -124,6 +125,12 @@ private function generateAvatar(): void
$this->contact->save();
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function log(): void
{
CreateAuditLog::dispatch([
diff --git a/domains/Contact/ManageContact/Services/MoveContactToAnotherVault.php b/domains/Contact/ManageContact/Services/MoveContactToAnotherVault.php
index 9927815501c..2caf074a72a 100644
--- a/domains/Contact/ManageContact/Services/MoveContactToAnotherVault.php
+++ b/domains/Contact/ManageContact/Services/MoveContactToAnotherVault.php
@@ -9,6 +9,7 @@
use App\Models\Contact;
use App\Models\Vault;
use App\Services\BaseService;
+use Carbon\Carbon;
class MoveContactToAnotherVault extends BaseService implements ServiceInterface
{
@@ -57,6 +58,7 @@ public function execute(array $data): Contact
$this->data = $data;
$this->validate();
$this->move();
+ $this->updateLastEditedDate();
$this->log();
return $this->contact;
@@ -85,6 +87,12 @@ private function move(): void
$this->contact->save();
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function log(): void
{
CreateAuditLog::dispatch([
diff --git a/domains/Contact/ManageContact/Services/ToggleArchiveContact.php b/domains/Contact/ManageContact/Services/ToggleArchiveContact.php
index c36979e362a..7c15e2ac7cb 100644
--- a/domains/Contact/ManageContact/Services/ToggleArchiveContact.php
+++ b/domains/Contact/ManageContact/Services/ToggleArchiveContact.php
@@ -6,6 +6,7 @@
use App\Models\Contact;
use App\Models\ContactFeedItem;
use App\Services\BaseService;
+use Carbon\Carbon;
class ToggleArchiveContact extends BaseService implements ServiceInterface
{
@@ -55,6 +56,7 @@ public function execute(array $data): Contact
$this->contact->listed = ! $this->contact->listed;
$this->contact->save();
+ $this->updateLastEditedDate();
$this->createFeedItem();
return $this->contact;
@@ -65,6 +67,12 @@ private function validate(): void
$this->validateRules($this->data);
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function createFeedItem(): void
{
ContactFeedItem::create([
diff --git a/domains/Contact/ManageContact/Services/UpdateContact.php b/domains/Contact/ManageContact/Services/UpdateContact.php
index 1e748c0bf4c..26861a472bb 100644
--- a/domains/Contact/ManageContact/Services/UpdateContact.php
+++ b/domains/Contact/ManageContact/Services/UpdateContact.php
@@ -84,6 +84,7 @@ public function execute(array $data): Contact
$this->contact->last_updated_at = Carbon::now();
$this->contact->save();
+ $this->updateLastEditedDate();
$this->log();
$this->createFeedItem();
@@ -105,6 +106,12 @@ private function validate(): void
}
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function log(): void
{
CreateAuditLog::dispatch([
diff --git a/domains/Contact/ManageContact/Services/UpdateContactTemplate.php b/domains/Contact/ManageContact/Services/UpdateContactTemplate.php
index 1855d9fc720..30ca4dcced3 100644
--- a/domains/Contact/ManageContact/Services/UpdateContactTemplate.php
+++ b/domains/Contact/ManageContact/Services/UpdateContactTemplate.php
@@ -58,6 +58,7 @@ public function execute(array $data): Contact
$this->validate();
$this->update();
+ $this->updateLastEditedDate();
$this->log();
return $this->contact;
@@ -78,6 +79,12 @@ private function update(): void
$this->contact->save();
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function log(): void
{
CreateAuditLog::dispatch([
diff --git a/domains/Contact/ManageContact/Web/ViewHelpers/ContactShowViewHelper.php b/domains/Contact/ManageContact/Web/ViewHelpers/ContactShowViewHelper.php
index 847becdadb1..6248a11e787 100644
--- a/domains/Contact/ManageContact/Web/ViewHelpers/ContactShowViewHelper.php
+++ b/domains/Contact/ManageContact/Web/ViewHelpers/ContactShowViewHelper.php
@@ -7,6 +7,7 @@
use App\Contact\ManageContactAddresses\Web\ViewHelpers\ModuleContactAddressesViewHelper;
use App\Contact\ManageContactFeed\Web\ViewHelpers\ModuleFeedViewHelper;
use App\Contact\ManageContactImportantDates\Web\ViewHelpers\ModuleImportantDatesViewHelper;
+use App\Contact\ManageContactInformation\Web\ViewHelpers\ModuleContactInformationViewHelper;
use App\Contact\ManageContactName\Web\ViewHelpers\ModuleContactNameViewHelper;
use App\Contact\ManageGoals\Web\ViewHelpers\ModuleGoalsViewHelper;
use App\Contact\ManageGroups\Web\ViewHelpers\GroupsViewHelper;
@@ -232,6 +233,10 @@ public static function modules(TemplatePage $page, Contact $contact, User $user)
$data = ModuleGroupsViewHelper::data($contact);
}
+ if ($module->type == Module::TYPE_CONTACT_INFORMATION) {
+ $data = ModuleContactInformationViewHelper::data($contact, $user);
+ }
+
$modulesCollection->push([
'id' => $module->id,
'type' => $module->type,
diff --git a/domains/Contact/ManageContactImportantDates/Services/CreateContactImportantDate.php b/domains/Contact/ManageContactImportantDates/Services/CreateContactImportantDate.php
index 5715b4fd952..4d9bd299402 100644
--- a/domains/Contact/ManageContactImportantDates/Services/CreateContactImportantDate.php
+++ b/domains/Contact/ManageContactImportantDates/Services/CreateContactImportantDate.php
@@ -10,6 +10,7 @@
use App\Models\ContactImportantDate;
use App\Models\ContactImportantDateType;
use App\Services\BaseService;
+use Carbon\Carbon;
class CreateContactImportantDate extends BaseService implements ServiceInterface
{
@@ -71,6 +72,7 @@ public function execute(array $data): ContactImportantDate
'year' => $this->valueOrNull($data, 'year'),
]);
+ $this->updateLastEditedDate();
$this->log();
$this->createFeedItem();
@@ -88,6 +90,12 @@ private function validate(): void
}
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function log(): void
{
CreateAuditLog::dispatch([
diff --git a/domains/Contact/ManageContactInformation/Services/CreateContactInformation.php b/domains/Contact/ManageContactInformation/Services/CreateContactInformation.php
index 0d5cc9c7020..d1393c5493d 100644
--- a/domains/Contact/ManageContactInformation/Services/CreateContactInformation.php
+++ b/domains/Contact/ManageContactInformation/Services/CreateContactInformation.php
@@ -8,11 +8,13 @@
use App\Models\ContactInformation;
use App\Models\ContactInformationType;
use App\Services\BaseService;
+use Carbon\Carbon;
class CreateContactInformation extends BaseService implements ServiceInterface
{
private ContactInformation $contactInformation;
private ContactInformationType $contactInformationType;
+ private array $data;
/**
* Get the validation rules that apply to the service.
@@ -54,20 +56,36 @@ public function permissions(): array
*/
public function execute(array $data): ContactInformation
{
- $this->validateRules($data);
+ $this->data = $data;
+ $this->validate();
+ $this->create();
+ $this->updateLastEditedDate();
+ $this->log();
+
+ return $this->contactInformation;
+ }
- $this->contactInformationType = ContactInformationType::where('account_id', $data['account_id'])
- ->findOrFail($data['contact_information_type_id']);
+ private function validate(): void
+ {
+ $this->validateRules($this->data);
+
+ $this->contactInformationType = ContactInformationType::where('account_id', $this->data['account_id'])
+ ->findOrFail($this->data['contact_information_type_id']);
+ }
+ private function create(): void
+ {
$this->contactInformation = ContactInformation::create([
'contact_id' => $this->contact->id,
'type_id' => $this->contactInformationType->id,
- 'data' => $data['data'],
+ 'data' => $this->data['data'],
]);
+ }
- $this->log();
-
- return $this->contactInformation;
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
}
private function log(): void
diff --git a/domains/Contact/ManageContactInformation/Services/DestroyContactInformation.php b/domains/Contact/ManageContactInformation/Services/DestroyContactInformation.php
index 7c9f17eb789..428844b62a7 100644
--- a/domains/Contact/ManageContactInformation/Services/DestroyContactInformation.php
+++ b/domains/Contact/ManageContactInformation/Services/DestroyContactInformation.php
@@ -3,11 +3,10 @@
namespace App\Contact\ManageContactInformation\Services;
use App\Interfaces\ServiceInterface;
-use App\Jobs\CreateAuditLog;
-use App\Jobs\CreateContactLog;
use App\Models\ContactInformation;
use App\Models\ContactInformationType;
use App\Services\BaseService;
+use Carbon\Carbon;
class DestroyContactInformation extends BaseService implements ServiceInterface
{
@@ -26,7 +25,6 @@ public function rules(): array
'vault_id' => 'required|integer|exists:vaults,id',
'author_id' => 'required|integer|exists:users,id',
'contact_id' => 'required|integer|exists:contacts,id',
- 'contact_information_type_id' => 'required|integer|exists:contact_information_types,id',
'contact_information_id' => 'required|integer|exists:contact_information,id',
];
}
@@ -53,42 +51,28 @@ public function permissions(): array
*/
public function execute(array $data): void
{
- $this->validateRules($data);
-
- $this->contactInformationType = ContactInformationType::where('account_id', $data['account_id'])
- ->findOrFail($data['contact_information_type_id']);
-
- $this->contactInformation = ContactInformation::where('contact_id', $this->contact->id)
- ->where('type_id', $data['contact_information_type_id'])
- ->findOrFail($data['contact_information_id']);
+ $this->data = $data;
+ $this->validate();
$this->contactInformation->delete();
- $this->log();
+ $this->updateLastEditedDate();
}
- private function log(): void
+ private function validate(): void
{
- CreateAuditLog::dispatch([
- 'account_id' => $this->author->account_id,
- 'author_id' => $this->author->id,
- 'author_name' => $this->author->name,
- 'action_name' => 'contact_information_destroyed',
- 'objects' => json_encode([
- 'contact_id' => $this->contact->id,
- 'contact_name' => $this->contact->name,
- 'contact_information_type_name' => $this->contactInformationType->name,
- ]),
- ])->onQueue('low');
+ $this->validateRules($this->data);
+
+ $this->contactInformation = ContactInformation::where('contact_id', $this->contact->id)
+ ->findOrFail($this->data['contact_information_id']);
+
+ ContactInformationType::where('account_id', $this->data['account_id'])
+ ->findOrFail($this->contactInformation->contactInformationType->id);
+ }
- CreateContactLog::dispatch([
- 'contact_id' => $this->contact->id,
- 'author_id' => $this->author->id,
- 'author_name' => $this->author->name,
- 'action_name' => 'contact_information_destroyed',
- 'objects' => json_encode([
- 'contact_information_type_name' => $this->contactInformationType->name,
- ]),
- ])->onQueue('low');
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
}
}
diff --git a/domains/Contact/ManageContactInformation/Services/UpdateContactInformation.php b/domains/Contact/ManageContactInformation/Services/UpdateContactInformation.php
index 01409eaec56..93d7d90f54b 100644
--- a/domains/Contact/ManageContactInformation/Services/UpdateContactInformation.php
+++ b/domains/Contact/ManageContactInformation/Services/UpdateContactInformation.php
@@ -8,6 +8,7 @@
use App\Models\ContactInformation;
use App\Models\ContactInformationType;
use App\Services\BaseService;
+use Carbon\Carbon;
class UpdateContactInformation extends BaseService implements ServiceInterface
{
@@ -55,21 +56,37 @@ public function permissions(): array
*/
public function execute(array $data): ContactInformation
{
- $this->validateRules($data);
+ $this->data = $data;
+ $this->validate();
+ $this->update();
+ $this->updateLastEditedDate();
+ $this->log();
- $this->contactInformationType = ContactInformationType::where('account_id', $data['account_id'])
- ->findOrFail($data['contact_information_type_id']);
+ return $this->contactInformation;
+ }
+
+ private function validate(): void
+ {
+ $this->validateRules($this->data);
+
+ $this->contactInformationType = ContactInformationType::where('account_id', $this->data['account_id'])
+ ->findOrFail($this->data['contact_information_type_id']);
$this->contactInformation = ContactInformation::where('contact_id', $this->contact->id)
- ->where('type_id', $data['contact_information_type_id'])
- ->findOrFail($data['contact_information_id']);
+ ->findOrFail($this->data['contact_information_id']);
+ }
- $this->contactInformation->data = $data['data'];
+ private function update(): void
+ {
+ $this->contactInformation->data = $this->data['data'];
+ $this->contactInformation->type_id = $this->data['contact_information_type_id'];
$this->contactInformation->save();
+ }
- $this->log();
-
- return $this->contactInformation;
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
}
private function log(): void
diff --git a/domains/Contact/ManageContactInformation/Web/Controllers/ContactInformationController.php b/domains/Contact/ManageContactInformation/Web/Controllers/ContactInformationController.php
new file mode 100644
index 00000000000..4e676652285
--- /dev/null
+++ b/domains/Contact/ManageContactInformation/Web/Controllers/ContactInformationController.php
@@ -0,0 +1,70 @@
+execute([
+ 'account_id' => Auth::user()->account_id,
+ 'author_id' => Auth::user()->id,
+ 'vault_id' => $vaultId,
+ 'contact_id' => $contactId,
+ 'contact_information_type_id' => $request->input('contact_information_type_id'),
+ 'data' => $request->input('data'),
+ ]);
+
+ $contact = Contact::find($contactId);
+
+ return response()->json([
+ 'data' => ModuleContactInformationViewHelper::dto($contact, $info),
+ ], 201);
+ }
+
+ public function update(Request $request, int $vaultId, int $contactId, int $infoId)
+ {
+ $data = [
+ 'account_id' => Auth::user()->account_id,
+ 'author_id' => Auth::user()->id,
+ 'vault_id' => $vaultId,
+ 'contact_id' => $contactId,
+ 'contact_information_id' => $infoId,
+ 'contact_information_type_id' => $request->input('contact_information_type_id'),
+ 'data' => $request->input('data'),
+ ];
+
+ $info = (new UpdateContactInformation())->execute($data);
+ $contact = Contact::find($contactId);
+
+ return response()->json([
+ 'data' => ModuleContactInformationViewHelper::dto($contact, $info),
+ ], 200);
+ }
+
+ public function destroy(Request $request, int $vaultId, int $contactId, int $infoId)
+ {
+ $data = [
+ 'account_id' => Auth::user()->account_id,
+ 'author_id' => Auth::user()->id,
+ 'vault_id' => $vaultId,
+ 'contact_id' => $contactId,
+ 'contact_information_id' => $infoId,
+ ];
+
+ (new DestroyContactInformation())->execute($data);
+
+ return response()->json([
+ 'data' => true,
+ ], 200);
+ }
+}
diff --git a/domains/Contact/ManageContactInformation/Web/ViewHelpers/ModuleContactInformationViewHelper.php b/domains/Contact/ManageContactInformation/Web/ViewHelpers/ModuleContactInformationViewHelper.php
new file mode 100644
index 00000000000..a2165ac2688
--- /dev/null
+++ b/domains/Contact/ManageContactInformation/Web/ViewHelpers/ModuleContactInformationViewHelper.php
@@ -0,0 +1,65 @@
+contactInformation()->with('contactInformationType')->get();
+
+ $infosCollection = $infos->map(function ($info) use ($contact) {
+ return self::dto($contact, $info);
+ });
+
+ $infoTypesCollection = $user->account
+ ->contactInformationTypes()
+ ->get()
+ ->map(function ($contactInformationType) {
+ return [
+ 'id' => $contactInformationType->id,
+ 'name' => $contactInformationType->name,
+ ];
+ });
+
+ return [
+ 'contact_information' => $infosCollection,
+ 'contact_information_types' => $infoTypesCollection,
+ 'url' => [
+ 'store' => route('contact.contact_information.store', [
+ 'vault' => $contact->vault_id,
+ 'contact' => $contact->id,
+ ]),
+ ],
+ ];
+ }
+
+ public static function dto(Contact $contact, ContactInformation $info): array
+ {
+ return [
+ 'id' => $info->id,
+ 'label' => $info->name,
+ 'data' => $info->contactInformationType->protocol ? $info->contactInformationType->protocol.$info->data : $info->data,
+ 'contact_information_type' => [
+ 'id' => $info->contactInformationType->id,
+ 'name' => $info->contactInformationType->name,
+ ],
+ 'url' => [
+ 'update' => route('contact.contact_information.update', [
+ 'vault' => $contact->vault_id,
+ 'contact' => $contact->id,
+ 'info' => $info->id,
+ ]),
+ 'destroy' => route('contact.contact_information.destroy', [
+ 'vault' => $contact->vault_id,
+ 'contact' => $contact->id,
+ 'info' => $info->id,
+ ]),
+ ],
+ ];
+ }
+}
diff --git a/domains/Contact/ManageGroups/Services/AddContactToGroup.php b/domains/Contact/ManageGroups/Services/AddContactToGroup.php
index c08ad604387..2aea5b78f29 100644
--- a/domains/Contact/ManageGroups/Services/AddContactToGroup.php
+++ b/domains/Contact/ManageGroups/Services/AddContactToGroup.php
@@ -9,6 +9,7 @@
use App\Models\GroupType;
use App\Models\GroupTypeRole;
use App\Services\BaseService;
+use Carbon\Carbon;
class AddContactToGroup extends BaseService implements ServiceInterface
{
@@ -69,6 +70,7 @@ public function execute(array $data): Group
}
$this->createFeedItem();
+ $this->updateLastEditedDate();
return $this->group;
}
@@ -88,6 +90,12 @@ private function validate(): void
}
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function createFeedItem(): void
{
$feedItem = ContactFeedItem::create([
diff --git a/domains/Contact/ManageGroups/Services/RemoveContactFromGroup.php b/domains/Contact/ManageGroups/Services/RemoveContactFromGroup.php
index 3660161fa1e..12dfd2787c3 100644
--- a/domains/Contact/ManageGroups/Services/RemoveContactFromGroup.php
+++ b/domains/Contact/ManageGroups/Services/RemoveContactFromGroup.php
@@ -7,6 +7,7 @@
use App\Models\ContactFeedItem;
use App\Models\Group;
use App\Services\BaseService;
+use Carbon\Carbon;
class RemoveContactFromGroup extends BaseService implements ServiceInterface
{
@@ -59,6 +60,7 @@ public function execute(array $data): Group
$this->contact->id,
]);
+ $this->updateLastEditedDate();
$this->createFeedItem();
return $this->group;
@@ -72,6 +74,12 @@ private function validate(): void
->findOrFail($this->data['group_id']);
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function createFeedItem(): void
{
$feedItem = ContactFeedItem::create([
diff --git a/domains/Contact/ManageJobInformation/Services/UpdateJobInformation.php b/domains/Contact/ManageJobInformation/Services/UpdateJobInformation.php
index 35e35e28f13..bdf53fb6875 100644
--- a/domains/Contact/ManageJobInformation/Services/UpdateJobInformation.php
+++ b/domains/Contact/ManageJobInformation/Services/UpdateJobInformation.php
@@ -7,6 +7,7 @@
use App\Models\Contact;
use App\Models\ContactFeedItem;
use App\Services\BaseService;
+use Carbon\Carbon;
class UpdateJobInformation extends BaseService implements ServiceInterface
{
@@ -63,6 +64,8 @@ public function execute(array $data): Contact
$this->contact->job_position = $this->valueOrNull($data, 'job_position');
$this->contact->save();
+ $this->updateLastEditedDate();
+
ContactFeedItem::create([
'author_id' => $this->author->id,
'contact_id' => $this->contact->id,
@@ -71,4 +74,10 @@ public function execute(array $data): Contact
return $this->contact;
}
+
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
}
diff --git a/domains/Contact/ManageLifeContactEvents/Services/CreateContactLifeEvent.php b/domains/Contact/ManageLifeContactEvents/Services/CreateContactLifeEvent.php
index 9ca3fb88153..e95fa23fafa 100644
--- a/domains/Contact/ManageLifeContactEvents/Services/CreateContactLifeEvent.php
+++ b/domains/Contact/ManageLifeContactEvents/Services/CreateContactLifeEvent.php
@@ -59,6 +59,7 @@ public function execute(array $data): ContactLifeEvent
{
$this->data = $data;
$this->validate();
+ $this->updateLastEditedDate();
$this->store();
return $this->contactLifeEvent;
@@ -74,6 +75,12 @@ private function validate(): void
->findOrFail($lifeEventType->lifeEventCategory->id);
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function store(): void
{
$this->contactLifeEvent = ContactLifeEvent::create([
diff --git a/domains/Contact/ManagePronouns/Services/RemovePronoun.php b/domains/Contact/ManagePronouns/Services/RemovePronoun.php
index 7a1131a4567..74397df57fd 100644
--- a/domains/Contact/ManagePronouns/Services/RemovePronoun.php
+++ b/domains/Contact/ManagePronouns/Services/RemovePronoun.php
@@ -7,6 +7,7 @@
use App\Jobs\CreateContactLog;
use App\Models\Pronoun;
use App\Services\BaseService;
+use Carbon\Carbon;
class RemovePronoun extends BaseService implements ServiceInterface
{
@@ -58,10 +59,17 @@ public function execute(array $data): void
$this->contact->pronoun_id = null;
$this->contact->save();
+ $this->updateLastEditedDate();
$this->log();
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function log(): void
{
CreateAuditLog::dispatch([
diff --git a/domains/Contact/ManageRelationships/Services/SetRelationship.php b/domains/Contact/ManageRelationships/Services/SetRelationship.php
index 84c0f29b765..05d1e801022 100644
--- a/domains/Contact/ManageRelationships/Services/SetRelationship.php
+++ b/domains/Contact/ManageRelationships/Services/SetRelationship.php
@@ -8,6 +8,7 @@
use App\Models\Contact;
use App\Models\RelationshipType;
use App\Services\BaseService;
+use Carbon\Carbon;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class SetRelationship extends BaseService implements ServiceInterface
@@ -66,6 +67,7 @@ public function execute(array $data): void
// create the relationships
$this->setRelationship($this->contact, $otherContact, $relationshipType);
+ $this->updateLastEditedDate();
$this->log($otherContact, $relationshipType);
}
@@ -78,6 +80,12 @@ private function setRelationship(Contact $contact, Contact $otherContact, Relati
]);
}
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
+ }
+
private function log(Contact $otherContact, RelationshipType $relationshipType): void
{
CreateAuditLog::dispatch([
diff --git a/domains/Contact/ManageRelationships/Services/UnsetRelationship.php b/domains/Contact/ManageRelationships/Services/UnsetRelationship.php
index c104c53a151..d7ac927fd1d 100644
--- a/domains/Contact/ManageRelationships/Services/UnsetRelationship.php
+++ b/domains/Contact/ManageRelationships/Services/UnsetRelationship.php
@@ -8,6 +8,7 @@
use App\Models\Contact;
use App\Models\RelationshipType;
use App\Services\BaseService;
+use Carbon\Carbon;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class UnsetRelationship extends BaseService implements ServiceInterface
@@ -75,6 +76,13 @@ public function execute(array $data): void
}
$this->log($otherContact);
+ $this->updateLastEditedDate();
+ }
+
+ private function updateLastEditedDate(): void
+ {
+ $this->contact->last_updated_at = Carbon::now();
+ $this->contact->save();
}
private function unsetRelationship(Contact $contact, Contact $otherContact): void
diff --git a/lang/en/app.php b/lang/en/app.php
index 1b65fb1739d..59e4341eaca 100644
--- a/lang/en/app.php
+++ b/lang/en/app.php
@@ -32,6 +32,7 @@
'breadcrumb_settings_personalize' => 'Personalize your account',
'breadcrumb_settings_personalize_templates' => 'Templates',
'breadcrumb_settings_personalize_relationship_types' => 'Relationship types',
+ 'breadcrumb_settings_personalize_contact_information_types' => 'Contact information types',
'notification_flash_changes_saved' => 'Changes saved',
@@ -58,6 +59,7 @@
'previous' => 'Previous',
'next' => 'Next',
'view_all' => 'View all',
+ 'view_map' => 'View on map',
'error_title' => 'đ Oops. An error occured.',
@@ -72,6 +74,7 @@
'default_template_page_feed' => 'Feed',
'default_template_page_information' => 'Information',
'default_template_page_life_events' => 'Life events & goals',
+ 'default_template_page_contact' => 'Ways to connect',
'module_names' => 'Contact name',
'module_avatar' => 'Avatar',
@@ -91,6 +94,7 @@
'module_goals' => 'Goals',
'module_addresses' => 'Addresses',
'module_groups' => 'Groups',
+ 'module_contact_information' => 'Contact information',
'module_option_default_number_of_items_to_display' => 'Default number of items to display',
diff --git a/lang/en/contact.php b/lang/en/contact.php
index e79eeea70e0..c17814977db 100644
--- a/lang/en/contact.php
+++ b/lang/en/contact.php
@@ -1,6 +1,23 @@
'Archive contact',
+ 'contact_unarchive_cta' => 'Unarchive contact',
+ 'contact_change_template_cta' => 'Change template',
+ 'contact_delete_cta' => 'Delete contact',
+ 'contact_archived' => 'The contact is archived',
+ 'contact_toggle_confirm' => 'Are you sure?',
+ 'contact_delete_confirm' => 'Are you sure? This will remove everything we know about this contact.',
+ 'contact_delete_success' => 'The contact has been deleted',
+
+ /***************************************************************
+ * MODULE: FEED
+ **************************************************************/
+
'feed_item_author_deleted' => 'Deleted user',
'feed_item_contact_information_updated' => 'updated the contact information',
'feed_item_important_date_created' => 'added an important date',
@@ -18,14 +35,43 @@
'feed_item_archived' => 'archived the contact',
'feed_item_unarchived' => 'unarchived the contact',
+ /***************************************************************
+ * MODULE: GROUP
+ **************************************************************/
+
'group_create' => '+ Create a group',
- 'contact_archive_cta' => 'Archive contact',
- 'contact_unarchive_cta' => 'Unarchive contact',
- 'contact_change_template_cta' => 'Change template',
- 'contact_delete_cta' => 'Delete contact',
- 'contact_archived' => 'The contact is archived',
- 'contact_toggle_confirm' => 'Are you sure?',
- 'contact_delete_confirm' => 'Are you sure? This will remove everything we know about this contact.',
- 'contact_delete_success' => 'The contact has been deleted',
+ /***************************************************************
+ * MODULE: ADDRESSES
+ **************************************************************/
+
+ 'addresses_title' => 'Addresses',
+ 'addresses_cta' => 'Add an address',
+ 'addresses_address_type' => 'Address type',
+ 'addresses_street' => 'Street',
+ 'addresses_city' => 'City',
+ 'addresses_province' => 'Province',
+ 'addresses_postal_code' => 'Postal code',
+ 'addresses_country' => 'Country',
+ 'addresses_inactive' => 'This address is not active anymore',
+ 'addresses_blank' => 'There are no active addresses yet.',
+ 'addresses_previous' => 'Previous addresses',
+ 'addresses_new_success' => 'The address has been created',
+ 'addresses_edit_success' => 'The address has been edited',
+ 'addresses_delete_confirm' => 'Are you sure? This will delete the address permanently.',
+ 'addresses_delete_success' => 'The address has been deleted',
+
+ /***************************************************************
+ * MODULE: CONTACT INFORMATION
+ **************************************************************/
+
+ 'contact_information_title' => 'Contact information',
+ 'contact_information_cta' => 'Add a contact information',
+ 'contact_information_blank' => 'There are no contact information yet.',
+ 'contact_information_name' => 'Content',
+ 'contact_information_type' => 'Type',
+ 'contact_information_new_success' => 'The contact information has been created',
+ 'contact_information_edit_success' => 'The contact information has been edited',
+ 'contact_information_delete_confirm' => 'Are you sure? This will delete the contact information permanently.',
+ 'contact_information_delete_success' => 'The contact information has been deleted',
];
diff --git a/lang/en/settings.php b/lang/en/settings.php
index 27a18bbcbf9..c0780455c0f 100644
--- a/lang/en/settings.php
+++ b/lang/en/settings.php
@@ -189,4 +189,20 @@
'personalize_relationship_types_update_success' =>'The relationship type has been updated',
'personalize_relationship_types_destroy_confirm' => 'Are you sure? This will delete all the relationships of this type for all the contacts that were using it.',
'personalize_relationship_types_destroy_success' =>'The relationship type has been deleted',
+
+ /***************************************************************
+ * PERSONNALIZE CONTACT TYPE INFORMATION
+ **************************************************************/
+
+ 'personalize_contact_information_types_title' => 'All the contact information types',
+ 'personalize_contact_information_types_cta' => 'Add a type',
+ 'personalize_contact_information_types_new_name' => 'Name',
+ 'personalize_contact_information_types_new_protocol' => 'Protocol',
+ 'personalize_contact_information_types_new_protocol_help' => 'A contact information can be clickable. For instance, a phone number can be clickable and launch the default application in your computer. If you do not know the protocol for the type you are adding, you can simply omit this field.',
+ 'personalize_contact_information_types_protocol' => 'Protocol: :name',
+ 'personalize_contact_information_types_blank' => 'Contact information types let you define how you can contact all your contacts (phone, email, âŠ).',
+ 'personalize_contact_information_types_new_success' => 'The contact information type has been created',
+ 'personalize_contact_information_types_edit_success' => 'The contact information type has been updated',
+ 'personalize_contact_information_types_delete_success' => 'The contact information type has been deleted',
+ 'personalize_contact_information_types_blank' => 'Are you sure? This will remove the contact information types from all contacts, but wonât delete the contacts themselves.',
];
diff --git a/lang/fr/app.php b/lang/fr/app.php
index cd34450ee51..d77f881d523 100644
--- a/lang/fr/app.php
+++ b/lang/fr/app.php
@@ -32,6 +32,7 @@
'breadcrumb_settings_personalize' => 'Personalisation du compte',
'breadcrumb_settings_personalize_templates' => 'ModĂšles',
'breadcrumb_settings_personalize_relationship_types' => 'Types de relation',
+ 'breadcrumb_settings_personalize_contact_information_types' => 'Types dâinformation de contact',
'notification_flash_changes_saved' => 'Changements effectués',
@@ -58,6 +59,7 @@
'previous' => 'Précédent',
'next' => 'Suivant',
'view_all' => 'Tout voir',
+ 'view_map' => 'Voir sur la carte',
'error_title' => 'đ Oops. Une erreur est survenue.',
@@ -72,6 +74,7 @@
'default_template_page_feed' => 'Flux',
'default_template_page_information' => 'Information',
'default_template_page_life_events' => 'ĂvĂšnements de vie et objectifs',
+ 'default_template_page_contact' => 'Connecter',
'module_names' => 'Nom du contact',
'module_avatar' => 'Avatar',
@@ -91,6 +94,7 @@
'module_goals' => 'Objectifs',
'module_addresses' => 'Adresses',
'module_groups' => 'Groupes',
+ 'module_contact_information' => 'Information de contact',
'module_option_default_number_of_items_to_display' => 'Nombre par dĂ©faut dâĂ©lĂ©ments Ă afficher',
diff --git a/lang/fr/contact.php b/lang/fr/contact.php
index ade69e5172e..f7633e90a75 100644
--- a/lang/fr/contact.php
+++ b/lang/fr/contact.php
@@ -1,6 +1,23 @@
'Archiver le contact',
+ 'contact_unarchive_cta' => 'DĂ©sarchiver le contact',
+ 'contact_change_template_cta' => 'Changer le modĂšle',
+ 'contact_delete_cta' => 'Supprimer le contact',
+ 'contact_archived' => 'Le contact est archivé',
+ 'contact_toggle_confirm' => 'Ătes vous sĂ»r ?',
+ 'contact_delete_confirm' => 'Ătes vous sĂ»r ? Cela va supprimer tout ce que lâon connaĂźt du contact.',
+ 'contact_delete_success' => 'Le contact a été supprimé',
+
+ /***************************************************************
+ * MODULE: FEED
+ **************************************************************/
+
'feed_item_author_deleted' => 'Utilisateur supprimé',
'feed_item_contact_information_updated' => 'a mis Ă jour les informations de contact',
'feed_item_important_date_created' => 'a ajouté une date importante',
@@ -18,14 +35,43 @@
'feed_item_archived' => 'a archivé le contact',
'feed_item_unarchived' => 'a désarchivé le contact',
+ /***************************************************************
+ * MODULE: GROUP
+ **************************************************************/
+
'group_create' => '+ Créer un groupe',
- 'contact_archive_cta' => 'Archiver le contact',
- 'contact_unarchive_cta' => 'DĂ©sarchiver le contact',
- 'contact_change_template_cta' => 'Changer le modĂšle',
- 'contact_delete_cta' => 'Supprimer le contact',
- 'contact_archived' => 'Le contact est archivé',
- 'contact_toggle_confirm' => 'Ătes vous sĂ»r ?',
- 'contact_delete_confirm' => 'Ătes vous sĂ»r ? Cela va supprimer tout ce que lâon connaĂźt du contact.',
- 'contact_delete_success' => 'Le contact a été supprimé',
+ /***************************************************************
+ * MODULE: ADDRESSES
+ **************************************************************/
+
+ 'addresses_title' => 'Adresses',
+ 'addresses_cta' => 'Ajouter une adresse',
+ 'addresses_address_type' => 'Type dâadresse',
+ 'addresses_street' => 'Rue',
+ 'addresses_city' => 'Ville',
+ 'addresses_province' => 'Province',
+ 'addresses_postal_code' => 'Code postal',
+ 'addresses_country' => 'Pays',
+ 'addresses_inactive' => 'Cette adresse nâest plus active',
+ 'addresses_blank' => 'Il nây a pas encore dâadresses actives.',
+ 'addresses_previous' => 'Adresses précédentes',
+ 'addresses_new_success' => 'Lâadresse a Ă©tĂ© crĂ©e',
+ 'addresses_edit_success' => 'Lâadresse a Ă©tĂ© mise Ă jour',
+ 'addresses_delete_confirm' => 'Ătes vous sĂ»r ? Cela va supprimer lâadresse de façon permanente.',
+ 'addresses_delete_success' => 'Lâadresse a Ă©tĂ© supprimĂ©e',
+
+ /***************************************************************
+ * MODULE: CONTACT INFORMATION
+ **************************************************************/
+
+ 'contact_information_title' => 'Information de contact',
+ 'contact_information_cta' => 'Ajouter une information de contact',
+ 'contact_information_blank' => 'Il nây a pas encore dâinformation de contact.',
+ 'contact_information_name' => 'Contenu',
+ 'contact_information_type' => 'Type',
+ 'contact_information_new_success' => 'Lâinformation de contact a Ă©tĂ© crĂ©e',
+ 'contact_information_edit_success' => 'Lâinformation de contact a Ă©tĂ© mise Ă jour',
+ 'contact_information_delete_confirm' => 'Ătes vous sĂ»r ? Cela va supprimer lâinformation de contact de façon permanente.',
+ 'contact_information_delete_success' => 'Lâinformation de contact a Ă©tĂ© supprimĂ©e',
];
diff --git a/lang/fr/settings.php b/lang/fr/settings.php
index cbdbcb5c3c6..0f84d6bd6ca 100644
--- a/lang/fr/settings.php
+++ b/lang/fr/settings.php
@@ -189,4 +189,20 @@
'personalize_relationship_types_update_success' => 'Le type de relation a été mis à jour',
'personalize_relationship_types_destroy_confirm' => 'Ătes-vous sĂ»r ? Cela va supprimer toutes les relations de ce type pour tous les contacts qui lâutilisaient.',
'personalize_relationship_types_destroy_success' => 'Le type de relation a été supprimé',
+
+ /***************************************************************
+ * PERSONNALIZE CONTACT TYPE INFORMATION
+ **************************************************************/
+
+ 'personalize_contact_information_types_title' => 'Tous les types dâinformation de contact',
+ 'personalize_contact_information_types_cta' => 'Ajouter un type',
+ 'personalize_contact_information_types_new_name' => 'Nom',
+ 'personalize_contact_information_types_new_protocol' => 'Protocole',
+ 'personalize_contact_information_types_new_protocol_help' => 'Une information de contact peut ĂȘtre cliquable. Par exemple, un numĂ©ro de tĂ©lĂ©phone peut ĂȘtre cliquable et ouvrir lâapplication par dĂ©faut sur votre ordinateur. Si vous ne connaissez pas le protocole pour le type que vous ajoutez, vous pouvez simplement omettre ce champ.',
+ 'personalize_contact_information_types_protocol' => 'Protocole : :name',
+ 'personalize_contact_information_types_blank' => 'Les types dâinformation de contact vous permettent de dĂ©finir les moyens de communication avec vos contacts (tĂ©lĂ©phone, courriel, âŠ).',
+ 'personalize_contact_information_types_new_success' => 'Le type dâinformation de contact a Ă©tĂ© crĂ©e',
+ 'personalize_contact_information_types_edit_success' => 'Le type dâinformation de contact a Ă©tĂ© mis Ă jour',
+ 'personalize_contact_information_types_delete_success' => 'Le type dâinformation de contact a Ă©tĂ© supprimĂ©',
+ 'personalize_contact_information_types_blank' => 'Ătes-vous sĂ»r ? Cela va supprimer toutes les informations de contact de ce type pour tous les contacts qui lâutilisaient, sans supprimer les contacts eux mĂȘmes.',
];
diff --git a/resources/js/Pages/Settings/Personalize/ContactInformationTypes/Index.vue b/resources/js/Pages/Settings/Personalize/ContactInformationTypes/Index.vue
index 34c0b7d9f63..8e894979431 100644
--- a/resources/js/Pages/Settings/Personalize/ContactInformationTypes/Index.vue
+++ b/resources/js/Pages/Settings/Personalize/ContactInformationTypes/Index.vue
@@ -54,7 +54,7 @@
[Protocol: {{ contactInformationType.protocol }}]
[{{
+ $t('settings.personalize_contact_information_types_protocol', {
+ name: contactInformationType.protocol,
+ })
+ }}]
- Contact information types let you define how you can contact all your contacts (phone, email, âŠ). + {{ $t('settings.personalize_contact_information_types_blank') }}
There are no active addresses yet.
+{{ $t('contact.addresses_blank') }}
{{ $t('contact.contact_information_blank') }}
+