From f08df37862b4c69245b9ae1c883544de560d529b Mon Sep 17 00:00:00 2001 From: payal-canyon Date: Thu, 10 Oct 2024 14:41:19 +0000 Subject: [PATCH 1/6] [AIDAPP-303]: Extend the model for knowledge base categories to have a slug value --- .config/psysh/psysh_history | 8 +++++++ .../KnowledgeBaseCategoryFactory.php | 1 + ...lug_to_knowledge_base_categories_table.php | 21 +++++++++++++++++++ .../Pages/CreateKnowledgeBaseCategory.php | 9 ++++++++ .../Pages/EditKnowledgeBaseCategory.php | 8 +++++++ .../Pages/ViewKnowledgeBaseCategory.php | 4 ++++ .../src/Models/KnowledgeBaseCategory.php | 1 + app/Features/KnowledgeBaseCategorySlug.php | 13 ++++++++++++ ...ture_flag_knowledge_base_category_slug.php | 16 ++++++++++++++ 9 files changed, 81 insertions(+) create mode 100644 .config/psysh/psysh_history create mode 100644 app-modules/knowledge-base/database/migrations/2024_10_10_115843_add_slug_to_knowledge_base_categories_table.php create mode 100644 app/Features/KnowledgeBaseCategorySlug.php create mode 100644 database/migrations/2024_10_10_142117_data_activate_feature_flag_knowledge_base_category_slug.php diff --git a/.config/psysh/psysh_history b/.config/psysh/psysh_history new file mode 100644 index 000000000..98f9a3670 --- /dev/null +++ b/.config/psysh/psysh_history @@ -0,0 +1,8 @@ +_HiStOrY_V2_ +AidingApp\134KnowledgeBase\134Models\134KnowledgeBaseCategory::factory(10)->create(); +AidingApp\134KnowledgeBase\134Models\134KnowledgeBaseCategory::factory(10)->create(); +clear +AidingApp\134KnowledgeBase\134Models\134KnowledgeBaseCategory::factory(10)->create(); +exit +AidingApp\134KnowledgeBase\134Models\134KnowledgeBaseCategory::factory(10)->create(); +exit diff --git a/app-modules/knowledge-base/database/factories/KnowledgeBaseCategoryFactory.php b/app-modules/knowledge-base/database/factories/KnowledgeBaseCategoryFactory.php index 7288f2729..2597d1451 100644 --- a/app-modules/knowledge-base/database/factories/KnowledgeBaseCategoryFactory.php +++ b/app-modules/knowledge-base/database/factories/KnowledgeBaseCategoryFactory.php @@ -52,6 +52,7 @@ public function definition(): array 'name' => str(fake()->word())->ucfirst()->toString(), 'description' => fake()->optional()->sentences(2, true), 'icon' => fake()->optional()->randomElement($this->icons()), + 'slug' => fake()->slug(), ]; } diff --git a/app-modules/knowledge-base/database/migrations/2024_10_10_115843_add_slug_to_knowledge_base_categories_table.php b/app-modules/knowledge-base/database/migrations/2024_10_10_115843_add_slug_to_knowledge_base_categories_table.php new file mode 100644 index 000000000..349df732c --- /dev/null +++ b/app-modules/knowledge-base/database/migrations/2024_10_10_115843_add_slug_to_knowledge_base_categories_table.php @@ -0,0 +1,21 @@ +string('slug')->unique()->nullable(); + }); + } + + public function down(): void + { + Schema::table('knowledge_base_categories', function (Blueprint $table) { + $table->dropColumn('slug'); + }); + } +}; diff --git a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/CreateKnowledgeBaseCategory.php b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/CreateKnowledgeBaseCategory.php index 4e8c70871..3ae1f7551 100644 --- a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/CreateKnowledgeBaseCategory.php +++ b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/CreateKnowledgeBaseCategory.php @@ -36,12 +36,14 @@ namespace AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseCategoryResource\Pages; +use App\Features\Slug; use Filament\Forms\Form; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Resources\Pages\CreateRecord; use App\Filament\Forms\Components\IconSelect; use AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseCategoryResource; +use App\Features\KnowledgeBaseCategorySlug; class CreateKnowledgeBaseCategory extends CreateRecord { @@ -56,6 +58,13 @@ public function form(Form $form): Form ->required() ->string(), IconSelect::make('icon'), + TextInput::make('slug') + ->regex('/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/') + ->unique() + ->maxLength(255) + ->required() + ->dehydrateStateUsing(fn (string $state): string => strtolower($state)) + ->visible(KnowledgeBaseCategorySlug::active()), Textarea::make('description') ->label('Description') ->nullable() diff --git a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/EditKnowledgeBaseCategory.php b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/EditKnowledgeBaseCategory.php index 587154b9a..903e3272d 100644 --- a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/EditKnowledgeBaseCategory.php +++ b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/EditKnowledgeBaseCategory.php @@ -42,6 +42,7 @@ use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Resources\Pages\EditRecord; +use App\Features\KnowledgeBaseCategorySlug; use App\Filament\Forms\Components\IconSelect; use AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseCategoryResource; @@ -58,6 +59,13 @@ public function form(Form $form): Form ->required() ->string(), IconSelect::make('icon'), + TextInput::make('slug') + ->regex('/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/') + ->unique(ignoreRecord: true) + ->maxLength(255) + ->required() + ->dehydrateStateUsing(fn (string $state): string => strtolower($state)) + ->visible(KnowledgeBaseCategorySlug::active()), Textarea::make('description') ->label('Description') ->nullable() diff --git a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/ViewKnowledgeBaseCategory.php b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/ViewKnowledgeBaseCategory.php index d406fab0b..12bece06d 100644 --- a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/ViewKnowledgeBaseCategory.php +++ b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/ViewKnowledgeBaseCategory.php @@ -40,6 +40,7 @@ use Filament\Infolists\Infolist; use Filament\Resources\Pages\ViewRecord; use Filament\Infolists\Components\Section; +use App\Features\KnowledgeBaseCategorySlug; use Filament\Infolists\Components\TextEntry; use AidingApp\KnowledgeBase\Models\KnowledgeBaseCategory; use AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseCategoryResource; @@ -63,6 +64,9 @@ public function infolist(Infolist $infolist): Infolist TextEntry::make('description') ->label('Description') ->columnSpanFull(), + TextEntry::make('slug') + ->hidden(fn (KnowledgeBaseCategory $record): bool => blank($record->slug)) + ->visible(KnowledgeBaseCategorySlug::active()), ]) ->columns(), ]); diff --git a/app-modules/knowledge-base/src/Models/KnowledgeBaseCategory.php b/app-modules/knowledge-base/src/Models/KnowledgeBaseCategory.php index c406ef37d..63402fd0a 100644 --- a/app-modules/knowledge-base/src/Models/KnowledgeBaseCategory.php +++ b/app-modules/knowledge-base/src/Models/KnowledgeBaseCategory.php @@ -57,6 +57,7 @@ class KnowledgeBaseCategory extends BaseModel implements Auditable 'name', 'description', 'icon', + 'slug', ]; public function knowledgeBaseItems(): HasMany diff --git a/app/Features/KnowledgeBaseCategorySlug.php b/app/Features/KnowledgeBaseCategorySlug.php new file mode 100644 index 000000000..8786516ce --- /dev/null +++ b/app/Features/KnowledgeBaseCategorySlug.php @@ -0,0 +1,13 @@ + Date: Thu, 10 Oct 2024 18:00:13 +0000 Subject: [PATCH 2/6] added slug in knowledge base category request factory --- .../CreateKnowledgeBaseCategoryRequestFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php b/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php index 810ba270d..bcafaa4af 100644 --- a/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php +++ b/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php @@ -44,6 +44,7 @@ public function definition(): array { return [ 'name' => $this->faker->word(), + 'slug' => fake()->slug(), ]; } } From c4e0d91ca64782d3403feba06bf7420488b29048 Mon Sep 17 00:00:00 2001 From: payal-canyon Date: Thu, 10 Oct 2024 18:43:19 +0000 Subject: [PATCH 3/6] solved the testcase --- .../CreateKnowledgeBaseCategoryRequestFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php b/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php index bcafaa4af..e37fdce3b 100644 --- a/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php +++ b/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php @@ -44,7 +44,7 @@ public function definition(): array { return [ 'name' => $this->faker->word(), - 'slug' => fake()->slug(), + 'slug' => $this->faker->slug(), ]; } } From 033b9868e2f2a7747483beef41ae565450fc9231 Mon Sep 17 00:00:00 2001 From: payal-canyon Date: Mon, 14 Oct 2024 05:39:27 +0000 Subject: [PATCH 4/6] Remove .config/psysh/psysh_history and add it to .gitignore --- .config/psysh/psysh_history | 8 -------- .gitignore | 1 + .../CreateKnowledgeBaseCategoryRequestFactory.php | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) delete mode 100644 .config/psysh/psysh_history diff --git a/.config/psysh/psysh_history b/.config/psysh/psysh_history deleted file mode 100644 index 98f9a3670..000000000 --- a/.config/psysh/psysh_history +++ /dev/null @@ -1,8 +0,0 @@ -_HiStOrY_V2_ -AidingApp\134KnowledgeBase\134Models\134KnowledgeBaseCategory::factory(10)->create(); -AidingApp\134KnowledgeBase\134Models\134KnowledgeBaseCategory::factory(10)->create(); -clear -AidingApp\134KnowledgeBase\134Models\134KnowledgeBaseCategory::factory(10)->create(); -exit -AidingApp\134KnowledgeBase\134Models\134KnowledgeBaseCategory::factory(10)->create(); -exit diff --git a/.gitignore b/.gitignore index 161b91810..a848d737c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ public/api-docs/* /rr _temp_graphql_parse_ide_helper_models.php /.bash_history +.config/psysh/psysh_history diff --git a/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php b/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php index e37fdce3b..3140fce49 100644 --- a/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php +++ b/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php @@ -43,8 +43,8 @@ class CreateKnowledgeBaseCategoryRequestFactory extends RequestFactory public function definition(): array { return [ - 'name' => $this->faker->word(), - 'slug' => $this->faker->slug(), + 'name' => fake()->word(), + 'slug' => fake()->slug(), ]; } } From dc8c48d7ee15c414bf32f8e99a602d45655a3dad Mon Sep 17 00:00:00 2001 From: payal-canyon Date: Mon, 14 Oct 2024 05:40:39 +0000 Subject: [PATCH 5/6] chore: fix enforcement of copyright on all files --- ...lug_to_knowledge_base_categories_table.php | 34 +++++++++++++++++++ app/Features/KnowledgeBaseCategorySlug.php | 34 +++++++++++++++++++ ...ture_flag_knowledge_base_category_slug.php | 34 +++++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/app-modules/knowledge-base/database/migrations/2024_10_10_115843_add_slug_to_knowledge_base_categories_table.php b/app-modules/knowledge-base/database/migrations/2024_10_10_115843_add_slug_to_knowledge_base_categories_table.php index 349df732c..d493db621 100644 --- a/app-modules/knowledge-base/database/migrations/2024_10_10_115843_add_slug_to_knowledge_base_categories_table.php +++ b/app-modules/knowledge-base/database/migrations/2024_10_10_115843_add_slug_to_knowledge_base_categories_table.php @@ -1,5 +1,39 @@ + + Copyright © 2016-2024, Canyon GBS LLC. All rights reserved. + + Aiding App™ is licensed under the Elastic License 2.0. For more details, + see + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Aiding App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + or contact us via email at legal@canyongbs.com. + + +*/ + use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; diff --git a/app/Features/KnowledgeBaseCategorySlug.php b/app/Features/KnowledgeBaseCategorySlug.php index 8786516ce..8502504d0 100644 --- a/app/Features/KnowledgeBaseCategorySlug.php +++ b/app/Features/KnowledgeBaseCategorySlug.php @@ -1,5 +1,39 @@ + + Copyright © 2016-2024, Canyon GBS LLC. All rights reserved. + + Aiding App™ is licensed under the Elastic License 2.0. For more details, + see + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Aiding App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + or contact us via email at legal@canyongbs.com. + + +*/ + namespace App\Features; use App\Support\AbstractFeatureFlag; diff --git a/database/migrations/2024_10_10_142117_data_activate_feature_flag_knowledge_base_category_slug.php b/database/migrations/2024_10_10_142117_data_activate_feature_flag_knowledge_base_category_slug.php index 2ec766f2d..3f00ef09e 100644 --- a/database/migrations/2024_10_10_142117_data_activate_feature_flag_knowledge_base_category_slug.php +++ b/database/migrations/2024_10_10_142117_data_activate_feature_flag_knowledge_base_category_slug.php @@ -1,5 +1,39 @@ + + Copyright © 2016-2024, Canyon GBS LLC. All rights reserved. + + Aiding App™ is licensed under the Elastic License 2.0. For more details, + see + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Aiding App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + or contact us via email at legal@canyongbs.com. + + +*/ + use App\Features\KnowledgeBaseCategorySlug; use Illuminate\Database\Migrations\Migration; From cff350e966ad883efd88a4bd969b37adf328e59c Mon Sep 17 00:00:00 2001 From: joelicatajr Date: Mon, 14 Oct 2024 05:42:20 +0000 Subject: [PATCH 6/6] chore: fix code style --- .../Pages/CreateKnowledgeBaseCategory.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/CreateKnowledgeBaseCategory.php b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/CreateKnowledgeBaseCategory.php index 3ae1f7551..f0ca78dd6 100644 --- a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/CreateKnowledgeBaseCategory.php +++ b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseCategoryResource/Pages/CreateKnowledgeBaseCategory.php @@ -36,14 +36,13 @@ namespace AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseCategoryResource\Pages; -use App\Features\Slug; use Filament\Forms\Form; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Resources\Pages\CreateRecord; +use App\Features\KnowledgeBaseCategorySlug; use App\Filament\Forms\Components\IconSelect; use AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseCategoryResource; -use App\Features\KnowledgeBaseCategorySlug; class CreateKnowledgeBaseCategory extends CreateRecord {