diff --git a/app/Jobs/SetupAccount.php b/app/Jobs/SetupAccount.php index e8854262f..f553c9f90 100644 --- a/app/Jobs/SetupAccount.php +++ b/app/Jobs/SetupAccount.php @@ -214,6 +214,22 @@ class SetupAccount implements ShouldQueue 'template_page_id' => $templatePageContact->id, 'module_id' => $module->id, ]); + + // companies + $module = (new CreateModule)->execute([ + 'account_id' => $this->user->account_id, + 'author_id' => $this->user->id, + 'name' => trans('app.module_companies'), + 'type' => Module::TYPE_COMPANY, + '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' => $templatePageContact->id, + 'module_id' => $module->id, + ]); } private function addTemplatePageFeed(): void diff --git a/app/Models/Company.php b/app/Models/Company.php new file mode 100644 index 000000000..9f306fa86 --- /dev/null +++ b/app/Models/Company.php @@ -0,0 +1,42 @@ + + */ + protected $fillable = [ + 'vault_id', + 'name', + 'type', + ]; + + /** + * Get the vault associated with the company. + * + * @return BelongsTo + */ + public function vault() + { + return $this->belongsTo(Vault::class); + } +} diff --git a/app/Models/Contact.php b/app/Models/Contact.php index 78e9668ae..83b9ce49e 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -31,6 +31,8 @@ class Contact extends Model 'can_be_deleted', 'template_id', 'last_updated_at', + 'company_id', + 'job_position', ]; /** @@ -223,6 +225,16 @@ class Contact extends Model return $this->belongsToMany(Loan::class, 'contact_loan', 'loanee_id'); } + /** + * Get the company associated with the contact. + * + * @return BelongsTo + */ + public function company(): BelongsTo + { + return $this->belongsTo(Company::class); + } + /** * Get the name of the contact, according to the user preference. * diff --git a/app/Models/Module.php b/app/Models/Module.php index e2944af64..372354458 100644 --- a/app/Models/Module.php +++ b/app/Models/Module.php @@ -18,6 +18,7 @@ class Module extends Model const TYPE_NOTES = 'notes'; const TYPE_CONTACT_NAMES = 'contact_names'; const TYPE_AVATAR = 'avatar'; + const TYPE_COMPANY = 'company'; const TYPE_FEED = 'feed'; const TYPE_GENDER_PRONOUN = 'gender_pronoun'; const TYPE_IMPORTANT_DATES = 'important_dates'; diff --git a/app/Models/Vault.php b/app/Models/Vault.php index cd2ba3159..c7b749cae 100644 --- a/app/Models/Vault.php +++ b/app/Models/Vault.php @@ -117,4 +117,14 @@ class Vault extends Model { return $this->hasMany(ContactImportantDateType::class); } + + /** + * Get the companies associated with the vault. + * + * @return HasMany + */ + public function companies() + { + return $this->hasMany(Company::class); + } } diff --git a/composer.lock b/composer.lock index 8472138d7..f5223b9d5 100644 --- a/composer.lock +++ b/composer.lock @@ -1357,16 +1357,16 @@ }, { "name": "laravel/framework", - "version": "v9.9.0", + "version": "v9.10.1", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "4d5a07640891b772188d7737348886a0222737d8" + "reference": "93414b1c7c0a56081d96c060bb850ac192d3d323" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/4d5a07640891b772188d7737348886a0222737d8", - "reference": "4d5a07640891b772188d7737348886a0222737d8", + "url": "https://api.github.com/repos/laravel/framework/zipball/93414b1c7c0a56081d96c060bb850ac192d3d323", + "reference": "93414b1c7c0a56081d96c060bb850ac192d3d323", "shasum": "" }, "require": { @@ -1532,7 +1532,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-04-19T15:01:23+00:00" + "time": "2022-04-28T13:18:25+00:00" }, { "name": "laravel/sanctum", @@ -1988,16 +1988,16 @@ }, { "name": "league/flysystem", - "version": "3.0.17", + "version": "3.0.18", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "29eb78cac0be0c22237c5e0f6f98234d97037d79" + "reference": "c8e137e594948240b03372e012344b07c61b9193" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/29eb78cac0be0c22237c5e0f6f98234d97037d79", - "reference": "29eb78cac0be0c22237c5e0f6f98234d97037d79", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/c8e137e594948240b03372e012344b07c61b9193", + "reference": "c8e137e594948240b03372e012344b07c61b9193", "shasum": "" }, "require": { @@ -2058,7 +2058,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.0.17" + "source": "https://github.com/thephpleague/flysystem/tree/3.0.18" }, "funding": [ { @@ -2074,7 +2074,7 @@ "type": "tidelift" } ], - "time": "2022-04-14T14:57:13+00:00" + "time": "2022-04-25T18:55:04+00:00" }, { "name": "league/mime-type-detection", @@ -3719,16 +3719,16 @@ }, { "name": "symfony/console", - "version": "v6.0.7", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "70dcf7b2ca2ea08ad6ebcc475f104a024fb5632e" + "reference": "0d00aa289215353aa8746a31d101f8e60826285c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/70dcf7b2ca2ea08ad6ebcc475f104a024fb5632e", - "reference": "70dcf7b2ca2ea08ad6ebcc475f104a024fb5632e", + "url": "https://api.github.com/repos/symfony/console/zipball/0d00aa289215353aa8746a31d101f8e60826285c", + "reference": "0d00aa289215353aa8746a31d101f8e60826285c", "shasum": "" }, "require": { @@ -3794,7 +3794,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.0.7" + "source": "https://github.com/symfony/console/tree/v6.0.8" }, "funding": [ { @@ -3810,7 +3810,7 @@ "type": "tidelift" } ], - "time": "2022-03-31T17:18:25+00:00" + "time": "2022-04-20T15:01:42+00:00" }, { "name": "symfony/css-selector", @@ -3946,16 +3946,16 @@ }, { "name": "symfony/error-handler", - "version": "v6.0.7", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "e600c54e5b30555eecea3ffe4314e58f832e78ee" + "reference": "5e2795163acbd13b3cd46835c9f8f6c5d0a3a280" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/e600c54e5b30555eecea3ffe4314e58f832e78ee", - "reference": "e600c54e5b30555eecea3ffe4314e58f832e78ee", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/5e2795163acbd13b3cd46835c9f8f6c5d0a3a280", + "reference": "5e2795163acbd13b3cd46835c9f8f6c5d0a3a280", "shasum": "" }, "require": { @@ -3997,7 +3997,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v6.0.7" + "source": "https://github.com/symfony/error-handler/tree/v6.0.8" }, "funding": [ { @@ -4013,7 +4013,7 @@ "type": "tidelift" } ], - "time": "2022-03-18T16:21:55+00:00" + "time": "2022-04-12T16:11:42+00:00" }, { "name": "symfony/event-dispatcher", @@ -4179,16 +4179,16 @@ }, { "name": "symfony/finder", - "version": "v6.0.3", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "8661b74dbabc23223f38c9b99d3f8ade71170430" + "reference": "af7edab28d17caecd1f40a9219fc646ae751c21f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/8661b74dbabc23223f38c9b99d3f8ade71170430", - "reference": "8661b74dbabc23223f38c9b99d3f8ade71170430", + "url": "https://api.github.com/repos/symfony/finder/zipball/af7edab28d17caecd1f40a9219fc646ae751c21f", + "reference": "af7edab28d17caecd1f40a9219fc646ae751c21f", "shasum": "" }, "require": { @@ -4220,7 +4220,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.0.3" + "source": "https://github.com/symfony/finder/tree/v6.0.8" }, "funding": [ { @@ -4236,20 +4236,20 @@ "type": "tidelift" } ], - "time": "2022-01-26T17:23:29+00:00" + "time": "2022-04-15T08:07:58+00:00" }, { "name": "symfony/http-foundation", - "version": "v6.0.7", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "c816b26f03b6902dba79b352c84a17f53d815f0d" + "reference": "c9c86b02d7ef6f44f3154acc7de42831518afe7c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/c816b26f03b6902dba79b352c84a17f53d815f0d", - "reference": "c816b26f03b6902dba79b352c84a17f53d815f0d", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/c9c86b02d7ef6f44f3154acc7de42831518afe7c", + "reference": "c9c86b02d7ef6f44f3154acc7de42831518afe7c", "shasum": "" }, "require": { @@ -4292,7 +4292,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v6.0.7" + "source": "https://github.com/symfony/http-foundation/tree/v6.0.8" }, "funding": [ { @@ -4308,20 +4308,20 @@ "type": "tidelift" } ], - "time": "2022-03-24T14:13:59+00:00" + "time": "2022-04-22T08:18:02+00:00" }, { "name": "symfony/http-kernel", - "version": "v6.0.7", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "9c03dab07a6aa336ffaadc15352b1d14f4ce01f5" + "reference": "7aaf1cdc9cc2ad47e926f624efcb679883a39ca7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/9c03dab07a6aa336ffaadc15352b1d14f4ce01f5", - "reference": "9c03dab07a6aa336ffaadc15352b1d14f4ce01f5", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/7aaf1cdc9cc2ad47e926f624efcb679883a39ca7", + "reference": "7aaf1cdc9cc2ad47e926f624efcb679883a39ca7", "shasum": "" }, "require": { @@ -4401,7 +4401,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v6.0.7" + "source": "https://github.com/symfony/http-kernel/tree/v6.0.8" }, "funding": [ { @@ -4417,20 +4417,20 @@ "type": "tidelift" } ], - "time": "2022-04-02T06:35:11+00:00" + "time": "2022-04-27T17:26:02+00:00" }, { "name": "symfony/mailer", - "version": "v6.0.7", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/mailer.git", - "reference": "f7343f94e7afecca2ad840b078f9d80200e1bd27" + "reference": "706af6b3e99ebcbc639c9c664f5579aaa869409b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mailer/zipball/f7343f94e7afecca2ad840b078f9d80200e1bd27", - "reference": "f7343f94e7afecca2ad840b078f9d80200e1bd27", + "url": "https://api.github.com/repos/symfony/mailer/zipball/706af6b3e99ebcbc639c9c664f5579aaa869409b", + "reference": "706af6b3e99ebcbc639c9c664f5579aaa869409b", "shasum": "" }, "require": { @@ -4475,7 +4475,7 @@ "description": "Helps sending emails", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/mailer/tree/v6.0.7" + "source": "https://github.com/symfony/mailer/tree/v6.0.8" }, "funding": [ { @@ -4491,20 +4491,20 @@ "type": "tidelift" } ], - "time": "2022-03-18T16:06:28+00:00" + "time": "2022-04-27T17:10:30+00:00" }, { "name": "symfony/mime", - "version": "v6.0.7", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "74266e396f812a2301536397a6360b6e6913c0d8" + "reference": "c1701e88ad0ca49fc6ad6cdf360bc0e1209fb5e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/74266e396f812a2301536397a6360b6e6913c0d8", - "reference": "74266e396f812a2301536397a6360b6e6913c0d8", + "url": "https://api.github.com/repos/symfony/mime/zipball/c1701e88ad0ca49fc6ad6cdf360bc0e1209fb5e1", + "reference": "c1701e88ad0ca49fc6ad6cdf360bc0e1209fb5e1", "shasum": "" }, "require": { @@ -4556,7 +4556,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v6.0.7" + "source": "https://github.com/symfony/mime/tree/v6.0.8" }, "funding": [ { @@ -4572,7 +4572,7 @@ "type": "tidelift" } ], - "time": "2022-03-13T20:10:05+00:00" + "time": "2022-04-12T16:11:42+00:00" }, { "name": "symfony/options-resolver", @@ -5298,16 +5298,16 @@ }, { "name": "symfony/process", - "version": "v6.0.7", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "e13f6757e267d687e20ec5b26ccfcbbe511cd8f4" + "reference": "d074154ea8b1443a96391f6e39f9e547b2dd01b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/e13f6757e267d687e20ec5b26ccfcbbe511cd8f4", - "reference": "e13f6757e267d687e20ec5b26ccfcbbe511cd8f4", + "url": "https://api.github.com/repos/symfony/process/zipball/d074154ea8b1443a96391f6e39f9e547b2dd01b9", + "reference": "d074154ea8b1443a96391f6e39f9e547b2dd01b9", "shasum": "" }, "require": { @@ -5339,7 +5339,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.0.7" + "source": "https://github.com/symfony/process/tree/v6.0.8" }, "funding": [ { @@ -5355,20 +5355,20 @@ "type": "tidelift" } ], - "time": "2022-03-18T16:21:55+00:00" + "time": "2022-04-12T16:11:42+00:00" }, { "name": "symfony/routing", - "version": "v6.0.5", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "a738b152426ac7fcb94bdab8188264652238bef1" + "reference": "74c40c9fc334acc601a32fcf4274e74fb3bac11e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/a738b152426ac7fcb94bdab8188264652238bef1", - "reference": "a738b152426ac7fcb94bdab8188264652238bef1", + "url": "https://api.github.com/repos/symfony/routing/zipball/74c40c9fc334acc601a32fcf4274e74fb3bac11e", + "reference": "74c40c9fc334acc601a32fcf4274e74fb3bac11e", "shasum": "" }, "require": { @@ -5427,7 +5427,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v6.0.5" + "source": "https://github.com/symfony/routing/tree/v6.0.8" }, "funding": [ { @@ -5443,7 +5443,7 @@ "type": "tidelift" } ], - "time": "2022-01-31T19:46:53+00:00" + "time": "2022-04-22T08:18:02+00:00" }, { "name": "symfony/service-contracts", @@ -5529,16 +5529,16 @@ }, { "name": "symfony/string", - "version": "v6.0.3", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2" + "reference": "ac0aa5c2282e0de624c175b68d13f2c8f2e2649d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/522144f0c4c004c80d56fa47e40e17028e2eefc2", - "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2", + "url": "https://api.github.com/repos/symfony/string/zipball/ac0aa5c2282e0de624c175b68d13f2c8f2e2649d", + "reference": "ac0aa5c2282e0de624c175b68d13f2c8f2e2649d", "shasum": "" }, "require": { @@ -5594,7 +5594,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.0.3" + "source": "https://github.com/symfony/string/tree/v6.0.8" }, "funding": [ { @@ -5610,20 +5610,20 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:55:41+00:00" + "time": "2022-04-22T08:18:02+00:00" }, { "name": "symfony/translation", - "version": "v6.0.7", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "b2792b39d74cf41ea3065f27fd2ddf0b556ac7a1" + "reference": "3d38cf8f8834148c4457681d539bc204de701501" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/b2792b39d74cf41ea3065f27fd2ddf0b556ac7a1", - "reference": "b2792b39d74cf41ea3065f27fd2ddf0b556ac7a1", + "url": "https://api.github.com/repos/symfony/translation/zipball/3d38cf8f8834148c4457681d539bc204de701501", + "reference": "3d38cf8f8834148c4457681d539bc204de701501", "shasum": "" }, "require": { @@ -5689,7 +5689,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v6.0.7" + "source": "https://github.com/symfony/translation/tree/v6.0.8" }, "funding": [ { @@ -5705,7 +5705,7 @@ "type": "tidelift" } ], - "time": "2022-03-31T17:18:25+00:00" + "time": "2022-04-22T08:18:02+00:00" }, { "name": "symfony/translation-contracts", @@ -5787,16 +5787,16 @@ }, { "name": "symfony/var-dumper", - "version": "v6.0.6", + "version": "v6.0.8", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "38358405ae948963c50a3aae3dfea598223ba15e" + "reference": "fa61dfb4bd3068df2492013dc65f3190e9f550c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/38358405ae948963c50a3aae3dfea598223ba15e", - "reference": "38358405ae948963c50a3aae3dfea598223ba15e", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/fa61dfb4bd3068df2492013dc65f3190e9f550c0", + "reference": "fa61dfb4bd3068df2492013dc65f3190e9f550c0", "shasum": "" }, "require": { @@ -5855,7 +5855,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.0.6" + "source": "https://github.com/symfony/var-dumper/tree/v6.0.8" }, "funding": [ { @@ -5871,7 +5871,7 @@ "type": "tidelift" } ], - "time": "2022-03-02T12:58:14+00:00" + "time": "2022-04-26T13:22:23+00:00" }, { "name": "tightenco/ziggy", @@ -7754,16 +7754,16 @@ }, { "name": "laravel/sail", - "version": "v1.13.10", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "cbf55e1a392724313f7726c38578b5e008df6a0f" + "reference": "453c66fde4109eb49e12299ffe3bf0d667983447" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/cbf55e1a392724313f7726c38578b5e008df6a0f", - "reference": "cbf55e1a392724313f7726c38578b5e008df6a0f", + "url": "https://api.github.com/repos/laravel/sail/zipball/453c66fde4109eb49e12299ffe3bf0d667983447", + "reference": "453c66fde4109eb49e12299ffe3bf0d667983447", "shasum": "" }, "require": { @@ -7810,7 +7810,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2022-04-14T18:29:22+00:00" + "time": "2022-04-27T13:10:22+00:00" }, { "name": "mockery/mockery", @@ -8645,16 +8645,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.5.7", + "version": "1.6.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "7fb7e2e1e9f3d59a26a413b2d3d5e47f0edb75ac" + "reference": "6128620b98292e0b69ea6d799871d77163681c8e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7fb7e2e1e9f3d59a26a413b2d3d5e47f0edb75ac", - "reference": "7fb7e2e1e9f3d59a26a413b2d3d5e47f0edb75ac", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6128620b98292e0b69ea6d799871d77163681c8e", + "reference": "6128620b98292e0b69ea6d799871d77163681c8e", "shasum": "" }, "require": { @@ -8680,7 +8680,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.5.7" + "source": "https://github.com/phpstan/phpstan/tree/1.6.3" }, "funding": [ { @@ -8700,7 +8700,7 @@ "type": "tidelift" } ], - "time": "2022-04-20T12:20:27+00:00" + "time": "2022-04-28T11:27:53+00:00" }, { "name": "phpunit/php-code-coverage", @@ -10264,16 +10264,16 @@ }, { "name": "spatie/ignition", - "version": "1.2.7", + "version": "1.2.9", "source": { "type": "git", "url": "https://github.com/spatie/ignition.git", - "reference": "2f059cf42b48f7c522efbba1c05ad59fc2c1a3f2" + "reference": "db25202fab2d5c14613b8914a1bb374998bbf870" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/ignition/zipball/2f059cf42b48f7c522efbba1c05ad59fc2c1a3f2", - "reference": "2f059cf42b48f7c522efbba1c05ad59fc2c1a3f2", + "url": "https://api.github.com/repos/spatie/ignition/zipball/db25202fab2d5c14613b8914a1bb374998bbf870", + "reference": "db25202fab2d5c14613b8914a1bb374998bbf870", "shasum": "" }, "require": { @@ -10330,7 +10330,7 @@ "type": "github" } ], - "time": "2022-03-29T08:48:34+00:00" + "time": "2022-04-23T20:37:21+00:00" }, { "name": "spatie/laravel-ignition", diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php new file mode 100644 index 000000000..772cec53c --- /dev/null +++ b/database/factories/CompanyFactory.php @@ -0,0 +1,31 @@ + Vault::factory(), + 'name' => $this->faker->name(), + 'type' => Company::TYPE_COMPANY, + ]; + } +} diff --git a/database/factories/ContactFactory.php b/database/factories/ContactFactory.php index 726bea24e..a5bc79555 100644 --- a/database/factories/ContactFactory.php +++ b/database/factories/ContactFactory.php @@ -3,6 +3,7 @@ namespace Database\Factories; use App\Models\Vault; +use App\Models\Company; use App\Models\Contact; use Illuminate\Database\Eloquent\Factories\Factory; @@ -30,6 +31,7 @@ class ContactFactory extends Factory 'nickname' => $this->faker->unique()->firstName, 'maiden_name' => $this->faker->unique()->name, 'can_be_deleted' => true, + 'company_id' => Company::factory(), ]; } } diff --git a/database/migrations/2020_04_23_133132_create_companies_table.php b/database/migrations/2020_04_23_133132_create_companies_table.php new file mode 100644 index 000000000..cbb8b9ad4 --- /dev/null +++ b/database/migrations/2020_04_23_133132_create_companies_table.php @@ -0,0 +1,38 @@ +id(); + $table->unsignedBigInteger('vault_id'); + $table->string('name'); + $table->string('type')->nullable(); + $table->timestamps(); + $table->foreign('vault_id')->references('id')->on('vaults')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('companies'); + } +}; diff --git a/database/migrations/2020_04_25_133132_create_contacts_table.php b/database/migrations/2020_04_25_133132_create_contacts_table.php index bdf61f6a1..0c280ece4 100644 --- a/database/migrations/2020_04_25_133132_create_contacts_table.php +++ b/database/migrations/2020_04_25_133132_create_contacts_table.php @@ -20,11 +20,13 @@ class CreateContactsTable extends Migration $table->unsignedBigInteger('gender_id')->nullable(); $table->unsignedBigInteger('pronoun_id')->nullable(); $table->unsignedBigInteger('template_id')->nullable(); + $table->unsignedBigInteger('company_id')->nullable(); $table->string('first_name'); $table->string('middle_name')->nullable(); $table->string('last_name')->nullable(); $table->string('nickname')->nullable(); $table->string('maiden_name')->nullable(); + $table->string('job_position')->nullable(); $table->boolean('can_be_deleted')->default(true); $table->datetime('last_updated_at')->nullable(); $table->timestamps(); @@ -32,6 +34,7 @@ class CreateContactsTable extends Migration $table->foreign('gender_id')->references('id')->on('genders')->onDelete('set null'); $table->foreign('pronoun_id')->references('id')->on('pronouns')->onDelete('set null'); $table->foreign('template_id')->references('id')->on('templates')->onDelete('set null'); + $table->foreign('company_id')->references('id')->on('companies')->onDelete('set null'); }); Schema::create('user_vault', function (Blueprint $table) { diff --git a/domains/Contact/ManageContact/Web/ViewHelpers/ContactShowViewHelper.php b/domains/Contact/ManageContact/Web/ViewHelpers/ContactShowViewHelper.php index 829834283..0a3f9b0db 100644 --- a/domains/Contact/ManageContact/Web/ViewHelpers/ContactShowViewHelper.php +++ b/domains/Contact/ManageContact/Web/ViewHelpers/ContactShowViewHelper.php @@ -14,6 +14,7 @@ use App\Contact\ManageLabels\Web\ViewHelpers\ModuleLabelViewHelper; use App\Contact\ManageAvatar\Web\ViewHelpers\ModuleAvatarViewHelper; use App\Contact\ManageContactFeed\Web\ViewHelpers\ModuleFeedViewHelper; use App\Contact\ManageReminders\Web\ViewHelpers\ModuleRemindersViewHelper; +use App\Contact\ManageJobInformation\Web\ViewHelpers\ModuleCompanyViewHelper; use App\Contact\ManagePronouns\Web\ViewHelpers\ModuleGenderPronounViewHelper; use App\Contact\ManageContactName\Web\ViewHelpers\ModuleContactNameViewHelper; use App\Contact\ManageContactImportantDates\Web\ViewHelpers\ModuleImportantDatesViewHelper; @@ -123,6 +124,10 @@ class ContactShowViewHelper $data = ModuleLabelViewHelper::data($contact); } + if ($module->type == Module::TYPE_COMPANY) { + $data = ModuleCompanyViewHelper::data($contact); + } + $modulesCollection->push([ 'id' => $module->id, 'type' => $module->type, diff --git a/domains/Contact/ManageJobInformation/Services/UpdateJobInformation.php b/domains/Contact/ManageJobInformation/Services/UpdateJobInformation.php new file mode 100644 index 000000000..8dd8d355d --- /dev/null +++ b/domains/Contact/ManageJobInformation/Services/UpdateJobInformation.php @@ -0,0 +1,67 @@ + 'required|integer|exists:accounts,id', + 'vault_id' => 'required|integer|exists:vaults,id', + 'author_id' => 'required|integer|exists:users,id', + 'contact_id' => 'required|integer|exists:contacts,id', + 'company_id' => 'nullable|integer|exists:companies,id', + 'job_position' => 'nullable|string|max:255', + ]; + } + + /** + * Get the permissions that apply to the user calling the service. + * + * @return array + */ + public function permissions(): array + { + return [ + 'author_must_belong_to_account', + 'vault_must_belong_to_account', + 'author_must_be_vault_editor', + 'contact_must_belong_to_vault', + ]; + } + + /** + * Update job information for the given contact. + * + * @param array $data + * @return Contact + */ + public function execute(array $data): Contact + { + $this->validateRules($data); + + if (! is_null($this->valueOrNull($data, 'company_id'))) { + $this->company = Company::where('vault_id', $data['vault_id']) + ->findOrFail($data['company_id']); + } + + $this->contact->company_id = $data['company_id'] ? $this->company->id : null; + $this->contact->job_position = $this->valueOrNull($data, 'job_position'); + $this->contact->save(); + + return $this->contact; + } +} diff --git a/domains/Contact/ManageJobInformation/Web/Controllers/ContactModuleJobInformationController.php b/domains/Contact/ManageJobInformation/Web/Controllers/ContactModuleJobInformationController.php new file mode 100644 index 000000000..c1a26a8c3 --- /dev/null +++ b/domains/Contact/ManageJobInformation/Web/Controllers/ContactModuleJobInformationController.php @@ -0,0 +1,62 @@ +json([ + 'data' => $collection, + ], 200); + } + + public function update(Request $request, int $vaultId, int $contactId) + { + if ($request->input('company_id')) { + $company = Company::findOrFail($request->input('company_id')); + } + + if ($request->input('company_name')) { + $data = [ + 'account_id' => Auth::user()->account_id, + 'author_id' => Auth::user()->id, + 'vault_id' => $vaultId, + 'name' => $request->input('company_name'), + 'type' => Company::TYPE_COMPANY, + ]; + + $company = (new CreateCompany)->execute($data); + } + + (new UpdateJobInformation)->execute([ + 'account_id' => Auth::user()->account_id, + 'author_id' => Auth::user()->id, + 'vault_id' => $vaultId, + 'contact_id' => $contactId, + 'company_id' => $company->id, + 'job_position' => $request->input('job_position'), + ]); + + $contact = Contact::findOrFail($contactId); + + return response()->json([ + 'data' => ModuleCompanyViewHelper::data($contact), + ], 200); + } +} diff --git a/domains/Contact/ManageJobInformation/Web/ViewHelpers/ModuleCompanyViewHelper.php b/domains/Contact/ManageJobInformation/Web/ViewHelpers/ModuleCompanyViewHelper.php new file mode 100644 index 000000000..a8b17b015 --- /dev/null +++ b/domains/Contact/ManageJobInformation/Web/ViewHelpers/ModuleCompanyViewHelper.php @@ -0,0 +1,51 @@ +company; + + return [ + 'job_position' => $contact->job_position, + 'company' => $company ? self::dto($company, $contact) : null, + 'url' => [ + 'index' => route('contact.companies.list.index', [ + 'vault' => $contact->vault_id, + 'contact' => $contact->id, + ]), + 'update' => route('contact.job_information.update', [ + 'vault' => $contact->vault_id, + 'contact' => $contact->id, + ]), + ], + ]; + } + + public static function list(Vault $vault, Contact $contact): Collection + { + $collection = $vault->companies()->orderBy('name', 'asc') + ->get()->map(function ($company) use ($contact) { + return self::dto($company, $contact); + }); + + return $collection; + } + + public static function dto(Company $company, Contact $contact): array + { + return [ + 'id' => $company->id, + 'name' => $company->name, + 'type' => $company->type, + 'selected' => $company->id === $contact->company_id, + ]; + } +} diff --git a/domains/Contact/ManageLabels/Services/AssignLabel.php b/domains/Contact/ManageLabels/Services/AssignLabel.php index fd0f716eb..c97b4c521 100644 --- a/domains/Contact/ManageLabels/Services/AssignLabel.php +++ b/domains/Contact/ManageLabels/Services/AssignLabel.php @@ -7,7 +7,6 @@ use App\Models\Label; use App\Jobs\CreateAuditLog; use App\Services\BaseService; use App\Jobs\CreateContactLog; -use App\Models\ContactFeedItem; use App\Interfaces\ServiceInterface; class AssignLabel extends BaseService implements ServiceInterface @@ -91,10 +90,5 @@ class AssignLabel extends BaseService implements ServiceInterface 'label_name' => $this->label->name, ]), ])->onQueue('low'); - - ContactFeedItem::create([ - 'contact_id' => $this->contact->id, - 'action' => ContactFeedItem::ACTION_LABEL_ADDED, - ]); } } diff --git a/domains/Vault/ManageCompanies/Services/CreateCompany.php b/domains/Vault/ManageCompanies/Services/CreateCompany.php new file mode 100644 index 000000000..f390b3cbc --- /dev/null +++ b/domains/Vault/ManageCompanies/Services/CreateCompany.php @@ -0,0 +1,73 @@ + 'required|integer|exists:accounts,id', + 'vault_id' => 'required|integer|exists:vaults,id', + 'author_id' => 'required|integer|exists:users,id', + 'name' => 'required|string|max:255', + 'type' => 'nullable|string|max:255', + ]; + } + + /** + * Get the permissions that apply to the user calling the service. + * + * @return array + */ + public function permissions(): array + { + return [ + 'author_must_belong_to_account', + 'vault_must_belong_to_account', + 'author_must_be_vault_editor', + ]; + } + + /** + * Create a company. + * + * @param array $data + * @return Company + */ + public function execute(array $data): Company + { + $this->data = $data; + + $this->validate(); + $this->create(); + + return $this->company; + } + + private function validate(): void + { + $this->validateRules($this->data); + } + + private function create(): void + { + $this->company = Company::create([ + 'vault_id' => $this->data['vault_id'], + 'name' => $this->data['name'], + 'type' => $this->valueOrNull($this->data, 'type'), + ]); + } +} diff --git a/domains/Vault/ManageCompanies/Web/ViewHelpers/CompanyViewHelper.php b/domains/Vault/ManageCompanies/Web/ViewHelpers/CompanyViewHelper.php new file mode 100644 index 000000000..ecb1a0633 --- /dev/null +++ b/domains/Vault/ManageCompanies/Web/ViewHelpers/CompanyViewHelper.php @@ -0,0 +1,30 @@ +companies()->orderBy('name', 'asc') + ->get()->map(function ($company) use ($vault) { + return self::dto($vault, $company); + }); + + return [ + 'companies' => $collection, + ]; + } + + public static function dto(Vault $vault, Company $company): array + { + return [ + 'id' => $company->id, + 'name' => $company->name, + 'type' => $company->type, + ]; + } +} diff --git a/resources/js/Pages/Vault/Contact/Show.vue b/resources/js/Pages/Vault/Contact/Show.vue index f2af6c97e..da6be0778 100644 --- a/resources/js/Pages/Vault/Contact/Show.vue +++ b/resources/js/Pages/Vault/Contact/Show.vue @@ -55,6 +55,8 @@ + + @@ -111,6 +113,7 @@ import Labels from '@/Shared/Modules/Labels'; import Reminders from '@/Shared/Modules/Reminders'; import Feed from '@/Shared/Modules/Feed'; import Loans from '@/Shared/Modules/Loans'; +import JobInformation from '@/Shared/Modules/JobInformation'; export default { components: { @@ -124,6 +127,7 @@ export default { Reminders, Feed, Loans, + JobInformation, }, props: { @@ -148,6 +152,7 @@ export default { notes: [], reminders: [], loans: [], + jobInformation: [], }; }, @@ -181,6 +186,11 @@ export default { this.labels = this.data.contact_information[this.data.contact_information.findIndex((x) => x.type == 'labels')].data; } + + if (this.data.contact_information.findIndex((x) => x.type == 'company') > -1) { + this.jobInformation = + this.data.contact_information[this.data.contact_information.findIndex((x) => x.type == 'company')].data; + } } // active page diff --git a/resources/js/Shared/Form/Dropdown.vue b/resources/js/Shared/Form/Dropdown.vue index cf97654bb..dcb896755 100644 --- a/resources/js/Shared/Form/Dropdown.vue +++ b/resources/js/Shared/Form/Dropdown.vue @@ -35,7 +35,6 @@ select { +.icon-sidebar { + top: -2px; +} + +.icon-note { + top: -1px; +} + +.label-list { + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + + li:last-child { + border-bottom: 0; + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + } + + li:hover:last-child { + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + } +} + + + + + + Job information + + + + + + + + + Close + + + + + + + + + + + + + + Or create a new one + + + + + + + + + + + + + + + + + + + + Not set + + + + {{ form.job_position }} + at + + {{ company_name }} + + + + + diff --git a/resources/js/Shared/Modules/Labels.vue b/resources/js/Shared/Modules/Labels.vue index 91a21f4f5..a2609beb4 100644 --- a/resources/js/Shared/Modules/Labels.vue +++ b/resources/js/Shared/Modules/Labels.vue @@ -47,7 +47,7 @@ + class="cursor-pointer text-xs text-gray-600"> Close @@ -59,10 +59,10 @@
+ Or create a new one +
Not set
+ + {{ form.job_position }} + at + + {{ company_name }} +