Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIDAPP-303]: Extend the model for knowledge base categories to have a slug value #276

Merged
merged 6 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ public/api-docs/*
/rr
_temp_graphql_parse_ide_helper_models.php
/.bash_history
.config/psysh/psysh_history
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/*
<COPYRIGHT>

Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.

Aiding App™ is licensed under the Elastic License 2.0. For more details,
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.>

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
<https://www.canyongbs.com> or contact us via email at legal@canyongbs.com.

</COPYRIGHT>
*/

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');
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class KnowledgeBaseCategory extends BaseModel implements Auditable
'name',
'description',
'icon',
'slug',
];

public function knowledgeBaseItems(): HasMany
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class CreateKnowledgeBaseCategoryRequestFactory extends RequestFactory
public function definition(): array
{
return [
'name' => $this->faker->word(),
'name' => fake()->word(),
'slug' => fake()->slug(),
];
}
}
47 changes: 47 additions & 0 deletions app/Features/KnowledgeBaseCategorySlug.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/*
<COPYRIGHT>

Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.

Aiding App™ is licensed under the Elastic License 2.0. For more details,
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.>

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
<https://www.canyongbs.com> or contact us via email at legal@canyongbs.com.

</COPYRIGHT>
*/

namespace App\Features;

use App\Support\AbstractFeatureFlag;

class KnowledgeBaseCategorySlug extends AbstractFeatureFlag
{
public function resolve(mixed $scope): mixed
{
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/*
<COPYRIGHT>

Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.

Aiding App™ is licensed under the Elastic License 2.0. For more details,
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.>

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
<https://www.canyongbs.com> or contact us via email at legal@canyongbs.com.

</COPYRIGHT>
*/

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();
}
};