diff --git a/app/Core/LogsActivity.php b/app/Core/LogsActivity.php index 26811e91..4314b0fb 100644 --- a/app/Core/LogsActivity.php +++ b/app/Core/LogsActivity.php @@ -22,7 +22,7 @@ public function getActivitylogOptions(): LogOptions ->logOnly($this->getFillable()) ->setDescriptionForEvent(fn(string $eventName) => new HtmlString( '
Google is an American technology services company founded in 1998 in Silicon Valley, California, by Larry Page and Sergey Brin, creators of the Google search engine. It has been a subsidiary of the Alphabet company since August 2015.
', false, 4, NULL, '2022-09-24 23:31:50', '2022-09-24 23:44:50'), +(2, 'Meta', null, 'Meta Platforms, Inc., better known by the trade name Meta, is an American company created in 2004 by Mark Zuckerberg. It is one of the giants of the Web, grouped under the acronym GAFAM, alongside Google, Apple, Amazon and Microsoft.
', true, 5, NULL, '2022-09-24 23:46:26', '2022-09-24 23:46:47'); diff --git a/database/help_desk.sql b/database/help_desk.sql index 7eef3af7..424bdd46 100644 --- a/database/help_desk.sql +++ b/database/help_desk.sql @@ -82,4 +82,8 @@ VALUES (1, 'Improvement', '#dbeafe', '#3b82f6', 'fa-arrow-up', NULL, '2022-09-19 'task'), (5, 'Bug', '#ef4444', '#fee2e2', 'fa-bug', NULL, '2022-09-19 10:37:37', '2022-09-19 11:31:04', 'bug'); +INSERT INTO `companies` (`id`, `name`, `logo`, `description`, `is_disabled`, `responsible_id`, `deleted_at`, `created_at`, `updated_at`) VALUES +(1, 'Google', null, 'Google is an American technology services company founded in 1998 in Silicon Valley, California, by Larry Page and Sergey Brin, creators of the Google search engine. It has been a subsidiary of the Alphabet company since August 2015.
', 0, 4, NULL, '2022-09-24 23:31:50', '2022-09-24 23:44:50'), +(2, 'Meta', null, 'Meta Platforms, Inc., better known by the trade name Meta, is an American company created in 2004 by Mark Zuckerberg. It is one of the giants of the Web, grouped under the acronym GAFAM, alongside Google, Apple, Amazon and Microsoft.
', 1, 5, NULL, '2022-09-24 23:46:26', '2022-09-24 23:46:47'); + SET foreign_key_checks = 1; diff --git a/database/migrations/2022_09_24_230950_create_companies_table.php b/database/migrations/2022_09_24_230950_create_companies_table.php new file mode 100644 index 00000000..36332555 --- /dev/null +++ b/database/migrations/2022_09_24_230950_create_companies_table.php @@ -0,0 +1,37 @@ +id(); + $table->string('name'); + $table->string('logo')->nullable(); + $table->longText('description')->nullable(); + $table->boolean('is_disabled')->default(false); + $table->foreignId('responsible_id')->constrained('users'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('companies'); + } +}; diff --git a/database/migrations/2022_09_25_154331_create_permission_tables.php b/database/migrations/2022_09_25_154331_create_permission_tables.php new file mode 100644 index 00000000..04c3278b --- /dev/null +++ b/database/migrations/2022_09_25_154331_create_permission_tables.php @@ -0,0 +1,141 @@ +bigIncrements('id'); // permission id + $table->string('name'); // For MySQL 8.0 use string('name', 125); + $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125); + $table->timestamps(); + + $table->unique(['name', 'guard_name']); + }); + + Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) { + $table->bigIncrements('id'); // role id + if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing + $table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable(); + $table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index'); + } + $table->string('name'); // For MySQL 8.0 use string('name', 125); + $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125); + $table->timestamps(); + if ($teams || config('permission.testing')) { + $table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']); + } else { + $table->unique(['name', 'guard_name']); + } + }); + + Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { + $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); + + $table->foreign(PermissionRegistrar::$pivotPermission) + ->references('id') // permission id + ->on($tableNames['permissions']) + ->onDelete('cascade'); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } else { + $table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } + + }); + + Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { + $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); + + $table->foreign(PermissionRegistrar::$pivotRole) + ->references('id') // role id + ->on($tableNames['roles']) + ->onDelete('cascade'); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } else { + $table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } + }); + + Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { + $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); + $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); + + $table->foreign(PermissionRegistrar::$pivotPermission) + ->references('id') // permission id + ->on($tableNames['permissions']) + ->onDelete('cascade'); + + $table->foreign(PermissionRegistrar::$pivotRole) + ->references('id') // role id + ->on($tableNames['roles']) + ->onDelete('cascade'); + + $table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary'); + }); + + app('cache') + ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) + ->forget(config('permission.cache.key')); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + $tableNames = config('permission.table_names'); + + if (empty($tableNames)) { + throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); + } + + Schema::drop($tableNames['role_has_permissions']); + Schema::drop($tableNames['model_has_roles']); + Schema::drop($tableNames['model_has_permissions']); + Schema::drop($tableNames['roles']); + Schema::drop($tableNames['permissions']); + } +} diff --git a/database/migrations/2022_09_25_163436_remove_role_from_users.php b/database/migrations/2022_09_25_163436_remove_role_from_users.php new file mode 100644 index 00000000..0895bd4f --- /dev/null +++ b/database/migrations/2022_09_25_163436_remove_role_from_users.php @@ -0,0 +1,32 @@ +dropColumn('role'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->string('role'); + }); + } +}; diff --git a/database/migrations/2022_09_25_165452_create_company_users_table.php b/database/migrations/2022_09_25_165452_create_company_users_table.php new file mode 100644 index 00000000..77f712a3 --- /dev/null +++ b/database/migrations/2022_09_25_165452_create_company_users_table.php @@ -0,0 +1,33 @@ +id(); + $table->foreignId('user_id')->constrained('users'); + $table->foreignId('company_id')->constrained('companies'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('company_users'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 7873482a..ac587451 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -15,5 +15,6 @@ class DatabaseSeeder extends Seeder public function run() { $this->call(FontAwesomeFreeSeeder::class); + $this->call(PermissionsSeeder::class); } } diff --git a/database/seeders/FontAwesomeFreeSeeder.php b/database/seeders/FontAwesomeFreeSeeder.php index bfe87ab6..451d2fa5 100644 --- a/database/seeders/FontAwesomeFreeSeeder.php +++ b/database/seeders/FontAwesomeFreeSeeder.php @@ -1476,7 +1476,9 @@ class FontAwesomeFreeSeeder extends Seeder public function run() { foreach (self::icons as $icon) { - Icon::create(['icon' => $icon]); + if (!Icon::where('icon', $icon)->count()) { + Icon::create(['icon' => $icon]); + } } } } diff --git a/database/seeders/PermissionsSeeder.php b/database/seeders/PermissionsSeeder.php new file mode 100644 index 00000000..c60ae1c0 --- /dev/null +++ b/database/seeders/PermissionsSeeder.php @@ -0,0 +1,62 @@ +count()) { + Permission::create(['name' => $permission]); + } + } + } +} diff --git a/lang/fr.json b/lang/fr.json index 196af923..7c18c3e6 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -285,5 +285,32 @@ "Use the section below to chat with the speakers of this ticket": "Utilisez la section ci-dessous pour échanger avec les intervenants de ce ticket", "Type a message..": "Tapez un message..", "Send": "Envoyer", - "No messages yet!": "Aucun message pour le moment !" + "No messages yet!": "Aucun message pour le moment !", + "Company name": "Nom de l'entreprise", + "Logo": "Logo", + "Companies": "Entreprises", + "Below is the list of configured companies in :app": "Ci-dessous est la liste des entreprises configurées sur :app", + "Create a new company": "Créer une nouvelle entreprise", + "Disable access to this company": "Désactiver l'accès à cette entreprise", + "Company created": "Entreprise créée", + "The company has been created": "L'entreprise est créée avec succès", + "Company updated": "Entreprise mise à jour", + "The company's details has been updated": "L'entreprise est mise à jour avec succès", + "Company deleted": "Entreprise supprimée", + "The company has been deleted": "L'entreprise est supprimée avec succès", + "Company deletion": "Suppression de l'entreprise", + "Are you sure you want to delete this company?": "Êtes-vous sûr de vouloir supprimer cette entreprise ?", + "Companies Management": "Gestion des entreprises", + "Here you can show and manage the companies list configured on :app": "Ici vous pouvez visualiser et gérer la liste des entreprises de :app", + "Manage companies": "Gérer les entreprises", + "Company activated": "Entreprise activée", + "Edit company": "Modifier l'entreprise", + "Use same permissions of": "Utiliser les mêmes permission que", + "Update the permissions of this user based on another user's permissions": "Mettre à jour les permissions de cet utilisateur en se basant sur les permissions d'un autre utilisateur", + "Assign all permissions": "Assigner toutes les permissions", + "Remove all permissions": "Enlever toutes les permissions", + "Company users": "Utilisateurs de l'entreprise", + "Yes": "Oui", + "No": "Non", + "All users": "Tous les utilisateurs" } diff --git a/public/images/administration/companies.jpeg b/public/images/administration/companies.jpeg new file mode 100644 index 00000000..a7f3d7fe Binary files /dev/null and b/public/images/administration/companies.jpeg differ diff --git a/resources/css/app.scss b/resources/css/app.scss index c996c870..6315e790 100644 --- a/resources/css/app.scss +++ b/resources/css/app.scss @@ -85,3 +85,9 @@ table { } } } + +.modal-container { + @apply w-full overflow-y-auto max-h-screen p-5; + + max-height: calc(100vh - 200px); +} diff --git a/resources/views/administration/companies.blade.php b/resources/views/administration/companies.blade.php new file mode 100644 index 00000000..9e0c231c --- /dev/null +++ b/resources/views/administration/companies.blade.php @@ -0,0 +1,7 @@ +@lang('Here you can show and manage the users list configured on :app', [ + @if(auth()->user()->hasAnyPermission(['View all users', 'View company users'])) +
@lang('Here you can show and manage the users list configured on :app', [ 'app' => config('app.name') ])
-@lang('Here you can show and manage the tickets statuses list configured on :app', [ - 'app' => config('app.name') - ])
-@lang('Here you can show and manage the companies list configured on :app', [ + 'app' => config('app.name') + ])
+@lang('Here you can show and manage the tickets priorities list configured on :app', [ - 'app' => config('app.name') - ])
-@lang('Here you can show and manage the tickets statuses list configured on :app', [ + 'app' => config('app.name') + ])
+@lang('Here you can show and manage the tickets types list configured on :app', [ - 'app' => config('app.name') - ])
-@lang('Here you can show and manage the tickets priorities list configured on :app', [ + 'app' => config('app.name') + ])
+@lang('Here you can see all activity logs of :app', [ - 'app' => config('app.name') - ])
-@lang('Here you can show and manage the tickets types list configured on :app', [ + 'app' => config('app.name') + ])
+ +@lang('Here you can see all activity logs of :app', [ + 'app' => config('app.name') + ])
+