Skip to content

Commit

Permalink
chore: fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
joelicatajr authored and github-actions[bot] committed Oct 15, 2024
1 parent 4a0518c commit 5b8b170
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
</COPYRIGHT>
*/

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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()
Expand Down
118 changes: 59 additions & 59 deletions app-modules/knowledge-base/src/Models/KnowledgeBaseItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions portals/knowledge-management/src/Components/Article.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
-->
<script setup>
import { ChevronRightIcon } from '@heroicons/vue/20/solid/index.js';
import Tags from './Tags.vue';
import Tags from './Tags.vue';
defineProps({
article: {
Expand All @@ -60,7 +60,7 @@
class="opacity-0 h-5 w-5 text-primary-600 transition-all group-hover:translate-x-2 group-hover:opacity-100"
/>
</div>
<Tags :tags="article.tags" :featured="article.featured"/>
<Tags :tags="article.tags" :featured="article.featured" />
</router-link>
</template>

Expand Down
10 changes: 5 additions & 5 deletions portals/knowledge-management/src/Components/Tags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
required: true,
},
featured: {
type: Boolean,
default: false
}
type: Boolean,
default: false,
},
});
</script>

<template>
<div class="flex flex-wrap gap-2">
<Badge v-if="featured" value="Featured"/>
<Badge v-for="tag in tags" :key="tag.id" :value="tag.name" />
<Badge v-if="featured" value="Featured" />
<Badge v-for="tag in tags" :key="tag.id" :value="tag.name" />
</div>
</template>
2 changes: 1 addition & 1 deletion portals/knowledge-management/src/Pages/ViewArticle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<span class="text-xs">Last updated: {{ article.lastUpdated }}</span>
</div>
</div>
<Tags :tags="article.tags" :featured="article.featured"/>
<Tags :tags="article.tags" :featured="article.featured" />
<hr class="my-4" />
<div v-html="DOMPurify.sanitize(article.content)"></div>
</div>
Expand Down

0 comments on commit 5b8b170

Please sign in to comment.