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/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..d493db621 --- /dev/null +++ b/app-modules/knowledge-base/database/migrations/2024_10_10_115843_add_slug_to_knowledge_base_categories_table.php @@ -0,0 +1,55 @@ + + + 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; + +return new class () extends Migration { + public function up(): void + { + Schema::table('knowledge_base_categories', function (Blueprint $table) { + $table->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..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 @@ -40,6 +40,7 @@ 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; @@ -56,6 +57,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-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php b/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php index 810ba270d..3140fce49 100644 --- a/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php +++ b/app-modules/knowledge-base/tests/KnowledgeBaseCategory/RequestFactories/CreateKnowledgeBaseCategoryRequestFactory.php @@ -43,7 +43,8 @@ class CreateKnowledgeBaseCategoryRequestFactory extends RequestFactory public function definition(): array { return [ - 'name' => $this->faker->word(), + 'name' => fake()->word(), + 'slug' => fake()->slug(), ]; } } diff --git a/app/Features/KnowledgeBaseCategorySlug.php b/app/Features/KnowledgeBaseCategorySlug.php new file mode 100644 index 000000000..8502504d0 --- /dev/null +++ b/app/Features/KnowledgeBaseCategorySlug.php @@ -0,0 +1,47 @@ + + + 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; + +class KnowledgeBaseCategorySlug extends AbstractFeatureFlag +{ + public function resolve(mixed $scope): mixed + { + return false; + } +} 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 new file mode 100644 index 000000000..3f00ef09e --- /dev/null +++ b/database/migrations/2024_10_10_142117_data_activate_feature_flag_knowledge_base_category_slug.php @@ -0,0 +1,50 @@ + + + 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; + +return new class () extends Migration { + public function up(): void + { + KnowledgeBaseCategorySlug::activate(); + } + + public function down(): void + { + KnowledgeBaseCategorySlug::deactivate(); + } +};