Skip to content

Commit

Permalink
chore: fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
jayushi-canyon authored and github-actions[bot] committed Oct 15, 2024
1 parent b46be0b commit 1441ba6
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 87 deletions.
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 = [
'is_featured' => 'boolean',
'public' => 'boolean',
'article_details' => 'array',
];

protected $fillable = [
'article_details',
'category_id',
'notes',
'public',
'quality_id',
'status_id',
'title',
'is_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 = [
'is_featured' => 'boolean',
'public' => 'boolean',
'article_details' => 'array',
];

protected $fillable = [
'article_details',
'category_id',
'notes',
'public',
'quality_id',
'status_id',
'title',
'is_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 @@ -46,33 +46,33 @@

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->is_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->is_featured : false,
]),
'portal_view_count' => $article->portal_view_count,
]);
}
}

0 comments on commit 1441ba6

Please sign in to comment.