Fixed breadcrumb for page detail

This commit is contained in:
Edward Yang 2023-05-17 11:19:30 +08:00
parent fcb6c888dc
commit f4657a9bed
1 changed files with 7 additions and 3 deletions

View File

@ -154,12 +154,16 @@ class PageCategoryRepo
}
/**
* @param $page
* @param $pageCategory
* @return string
*/
public static function getName($pageCategoryId)
public static function getName($pageCategory): string
{
// 根据 pageCategoryId 获取 name判断是否存在
if ($pageCategory instanceof PageCategory) {
return $pageCategory->description->title ?? '';
}
$pageCategoryId = (int)$pageCategory;
$pageCategory = PageCategory::query()->whereHas('description', function ($query) use ($pageCategoryId) {
$query->where('page_category_id', $pageCategoryId);
})->first();