From 5b8b1704faf26c3d6ea170a249d9dc796f4d9820 Mon Sep 17 00:00:00 2001 From: joelicatajr Date: Tue, 15 Oct 2024 09:12:24 +0000 Subject: [PATCH] chore: fix code style --- ...olumn_in_knowledge_base_articles_table.php | 7 +- .../Pages/CreateKnowledgeBaseItem.php | 6 +- .../Pages/EditKnowledgeBaseItemMetadata.php | 6 +- .../src/Models/KnowledgeBaseItem.php | 118 +++++++++--------- .../KnowledgeBaseArticleData.php | 18 +-- ...ledgeManagementPortalArticleController.php | 58 ++++----- ...edgeManagementPortalCategoryController.php | 4 +- ...ctivate_featured_flag_featured_article.php | 5 +- .../src/Components/Article.vue | 4 +- .../src/Components/Tags.vue | 10 +- .../src/Pages/ViewArticle.vue | 2 +- 11 files changed, 117 insertions(+), 121 deletions(-) diff --git a/app-modules/knowledge-base/database/migrations/2024_10_14_102603_add_featured_column_in_knowledge_base_articles_table.php b/app-modules/knowledge-base/database/migrations/2024_10_14_102603_add_featured_column_in_knowledge_base_articles_table.php index 3edd0c50c..18e48ea0d 100644 --- a/app-modules/knowledge-base/database/migrations/2024_10_14_102603_add_featured_column_in_knowledge_base_articles_table.php +++ b/app-modules/knowledge-base/database/migrations/2024_10_14_102603_add_featured_column_in_knowledge_base_articles_table.php @@ -34,12 +34,11 @@ */ -use Illuminate\Database\Migrations\Migration; -use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; -return new class extends Migration -{ +return new class () extends Migration { public function up(): void { Schema::table('knowledge_base_articles', function (Blueprint $table) { diff --git a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseItemResource/Pages/CreateKnowledgeBaseItem.php b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseItemResource/Pages/CreateKnowledgeBaseItem.php index f609cb464..280c6f4aa 100644 --- a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseItemResource/Pages/CreateKnowledgeBaseItem.php +++ b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseItemResource/Pages/CreateKnowledgeBaseItem.php @@ -37,7 +37,9 @@ namespace AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseItemResource\Pages; use Filament\Forms\Form; +use App\Features\FeaturedArticle; use App\Models\Scopes\TagsForClass; +use Filament\Forms\Components\Grid; use Filament\Forms\Components\Select; use Filament\Forms\Components\Toggle; use Filament\Forms\Components\Section; @@ -51,8 +53,6 @@ use AidingApp\KnowledgeBase\Models\KnowledgeBaseQuality; use AidingApp\KnowledgeBase\Models\KnowledgeBaseCategory; use AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseItemResource; -use App\Features\FeaturedArticle; -use Filament\Forms\Components\Grid; class CreateKnowledgeBaseItem extends CreateRecord { @@ -89,7 +89,7 @@ public function form(Form $form): Form ->relationship( 'tags', 'name', - fn(Builder $query) => $query->tap(new TagsForClass(new KnowledgeBaseItem())) + fn (Builder $query) => $query->tap(new TagsForClass(new KnowledgeBaseItem())) ) ->searchable() ->preload() diff --git a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseItemResource/Pages/EditKnowledgeBaseItemMetadata.php b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseItemResource/Pages/EditKnowledgeBaseItemMetadata.php index 5933f4081..f08280ee9 100644 --- a/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseItemResource/Pages/EditKnowledgeBaseItemMetadata.php +++ b/app-modules/knowledge-base/src/Filament/Resources/KnowledgeBaseItemResource/Pages/EditKnowledgeBaseItemMetadata.php @@ -36,7 +36,9 @@ namespace AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseItemResource\Pages; +use App\Features\FeaturedArticle; use App\Models\Scopes\TagsForClass; +use Filament\Forms\Components\Grid; use Filament\Forms\Components\Select; use Filament\Forms\Components\Toggle; use Filament\Forms\Components\Section; @@ -48,8 +50,6 @@ use AidingApp\KnowledgeBase\Models\KnowledgeBaseStatus; use AidingApp\KnowledgeBase\Models\KnowledgeBaseQuality; use AidingApp\KnowledgeBase\Models\KnowledgeBaseCategory; -use App\Features\FeaturedArticle; -use Filament\Forms\Components\Grid; class EditKnowledgeBaseItemMetadata { @@ -80,7 +80,7 @@ public function form(): array ->relationship( 'tags', 'name', - fn(Builder $query) => $query->tap(new TagsForClass(new KnowledgeBaseItem())) + fn (Builder $query) => $query->tap(new TagsForClass(new KnowledgeBaseItem())) ) ->searchable() ->preload() diff --git a/app-modules/knowledge-base/src/Models/KnowledgeBaseItem.php b/app-modules/knowledge-base/src/Models/KnowledgeBaseItem.php index 4c5f26a58..5b6efd1df 100644 --- a/app-modules/knowledge-base/src/Models/KnowledgeBaseItem.php +++ b/app-modules/knowledge-base/src/Models/KnowledgeBaseItem.php @@ -55,63 +55,63 @@ */ class KnowledgeBaseItem extends BaseModel implements Auditable, HasMedia, HasTags { - use AuditableTrait; - use HasUuids; - use InteractsWithMedia; - use SoftDeletes; - use InteractsWithTags; - - protected $table = 'knowledge_base_articles'; - - protected $casts = [ - 'featured' => 'boolean', - 'public' => 'boolean', - 'article_details' => 'array', - ]; - - protected $fillable = [ - 'article_details', - 'category_id', - 'notes', - 'public', - 'quality_id', - 'status_id', - 'title', - 'featured' - ]; - - public function quality(): BelongsTo - { - return $this->belongsTo(KnowledgeBaseQuality::class); - } - - public function status(): BelongsTo - { - return $this->belongsTo(KnowledgeBaseStatus::class); - } - - public function category(): BelongsTo - { - return $this->belongsTo(KnowledgeBaseCategory::class); - } - - public function division(): BelongsToMany - { - return $this->belongsToMany(Division::class); - } - - public function registerMediaCollections(): void - { - $this->addMediaCollection('article_details'); - } - - public function scopePublic($query) - { - return $query->where('public', true); - } - - protected function serializeDate(DateTimeInterface $date): string - { - return $date->format(config('project.datetime_format') ?? 'Y-m-d H:i:s'); - } + use AuditableTrait; + use HasUuids; + use InteractsWithMedia; + use SoftDeletes; + use InteractsWithTags; + + protected $table = 'knowledge_base_articles'; + + protected $casts = [ + 'featured' => 'boolean', + 'public' => 'boolean', + 'article_details' => 'array', + ]; + + protected $fillable = [ + 'article_details', + 'category_id', + 'notes', + 'public', + 'quality_id', + 'status_id', + 'title', + 'featured', + ]; + + public function quality(): BelongsTo + { + return $this->belongsTo(KnowledgeBaseQuality::class); + } + + public function status(): BelongsTo + { + return $this->belongsTo(KnowledgeBaseStatus::class); + } + + public function category(): BelongsTo + { + return $this->belongsTo(KnowledgeBaseCategory::class); + } + + public function division(): BelongsToMany + { + return $this->belongsToMany(Division::class); + } + + public function registerMediaCollections(): void + { + $this->addMediaCollection('article_details'); + } + + public function scopePublic($query) + { + return $query->where('public', true); + } + + protected function serializeDate(DateTimeInterface $date): string + { + return $date->format(config('project.datetime_format') ?? 'Y-m-d H:i:s'); + } } diff --git a/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php b/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php index b347de595..f38482e6d 100644 --- a/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php +++ b/app-modules/portal/src/DataTransferObjects/KnowledgeBaseArticleData.php @@ -40,13 +40,13 @@ class KnowledgeBaseArticleData extends Data { - public function __construct( - public string $id, - public ?string $categoryId, - public string $name, - public ?string $lastUpdated, - public ?string $content, - public ?array $tags, - public bool $featured, - ) {} + public function __construct( + public string $id, + public ?string $categoryId, + public string $name, + public ?string $lastUpdated, + public ?string $content, + public ?array $tags, + public bool $featured, + ) {} } diff --git a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php index 4d37bf524..eb87e1150 100644 --- a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php +++ b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalArticleController.php @@ -36,43 +36,43 @@ namespace AidingApp\Portal\Http\Controllers\KnowledgeManagementPortal; +use App\Features\FeaturedArticle; use Illuminate\Http\JsonResponse; use App\Http\Controllers\Controller; use AidingApp\KnowledgeBase\Models\KnowledgeBaseItem; use AidingApp\KnowledgeBase\Models\KnowledgeBaseCategory; use AidingApp\Portal\DataTransferObjects\KnowledgeBaseArticleData; use AidingApp\Portal\DataTransferObjects\KnowledgeBaseCategoryData; -use App\Features\FeaturedArticle; class KnowledgeManagementPortalArticleController extends Controller { - public function show(KnowledgeBaseCategory $category, KnowledgeBaseItem $article): JsonResponse - { - $article->increment('portal_view_count'); + public function show(KnowledgeBaseCategory $category, KnowledgeBaseItem $article): JsonResponse + { + $article->increment('portal_view_count'); - return response()->json([ - 'category' => KnowledgeBaseCategoryData::from([ - 'id' => $category->getKey(), - 'name' => $category->name, - 'description' => $category->description, - ]), - 'article' => KnowledgeBaseArticleData::from([ - 'id' => $article->getKey(), - 'categoryId' => $article->category_id, - 'name' => $article->title, - 'lastUpdated' => $article->updated_at->format('M d Y, h:m a'), - 'content' => $article->article_details ? tiptap_converter()->record($article, attribute: 'article_details')->asHTML($article->article_details) : '', - 'tags' => $article->tags() - ->orderBy('name') - ->select([ - 'id', - 'name', - ]) - ->get() - ->toArray(), - 'featured' => FeaturedArticle::active() ? $article->featured : false, - ]), - 'portal_view_count' => $article->portal_view_count, - ]); - } + return response()->json([ + 'category' => KnowledgeBaseCategoryData::from([ + 'id' => $category->getKey(), + 'name' => $category->name, + 'description' => $category->description, + ]), + 'article' => KnowledgeBaseArticleData::from([ + 'id' => $article->getKey(), + 'categoryId' => $article->category_id, + 'name' => $article->title, + 'lastUpdated' => $article->updated_at->format('M d Y, h:m a'), + 'content' => $article->article_details ? tiptap_converter()->record($article, attribute: 'article_details')->asHTML($article->article_details) : '', + 'tags' => $article->tags() + ->orderBy('name') + ->select([ + 'id', + 'name', + ]) + ->get() + ->toArray(), + 'featured' => FeaturedArticle::active() ? $article->featured : false, + ]), + 'portal_view_count' => $article->portal_view_count, + ]); + } } diff --git a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalCategoryController.php b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalCategoryController.php index 75664b76c..4f7eab560 100644 --- a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalCategoryController.php +++ b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalCategoryController.php @@ -36,11 +36,11 @@ namespace AidingApp\Portal\Http\Controllers\KnowledgeManagementPortal; +use App\Features\FeaturedArticle; use Illuminate\Http\JsonResponse; use App\Http\Controllers\Controller; use AidingApp\KnowledgeBase\Models\KnowledgeBaseCategory; use AidingApp\Portal\DataTransferObjects\KnowledgeBaseCategoryData; -use App\Features\FeaturedArticle; class KnowledgeManagementPortalCategoryController extends Controller { @@ -80,7 +80,7 @@ public function show(KnowledgeBaseCategory $category): JsonResponse $category->name = $category->title; $category->categoryId = $category->category_id; $category->id = $category->getKey(); - + $category->featured = FeaturedArticle::active() ? $category->featured : false; $category->tags = $category->tags() ->orderBy('name') diff --git a/database/migrations/2024_10_14_102853_data_activate_featured_flag_featured_article.php b/database/migrations/2024_10_14_102853_data_activate_featured_flag_featured_article.php index fd04e2b3d..f458baca2 100644 --- a/database/migrations/2024_10_14_102853_data_activate_featured_flag_featured_article.php +++ b/database/migrations/2024_10_14_102853_data_activate_featured_flag_featured_article.php @@ -36,11 +36,8 @@ use App\Features\FeaturedArticle; use Illuminate\Database\Migrations\Migration; -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class () extends Migration { public function up(): void { FeaturedArticle::activate(); diff --git a/portals/knowledge-management/src/Components/Article.vue b/portals/knowledge-management/src/Components/Article.vue index b0a8ed321..72da8cfe9 100644 --- a/portals/knowledge-management/src/Components/Article.vue +++ b/portals/knowledge-management/src/Components/Article.vue @@ -33,7 +33,7 @@ --> diff --git a/portals/knowledge-management/src/Pages/ViewArticle.vue b/portals/knowledge-management/src/Pages/ViewArticle.vue index c97138eed..45f5159c2 100644 --- a/portals/knowledge-management/src/Pages/ViewArticle.vue +++ b/portals/knowledge-management/src/Pages/ViewArticle.vue @@ -120,7 +120,7 @@ Last updated: {{ article.lastUpdated }} - +