|
@@ -288,6 +288,7 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
public function getWebsiteArticlett(array $data): array
|
|
|
{
|
|
|
+ // return Result::success($data['website_id']);
|
|
|
$category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
|
|
|
$category = array_values(array_unique($category->toArray()));
|
|
|
$result = [];
|
|
@@ -318,14 +319,17 @@ class NewsService implements NewsServiceInterface
|
|
|
$catid = $article->catid;
|
|
|
$pinyin = '';
|
|
|
$category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
- $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
- if ($category->pid != 0 && !empty($category->aLIas_pinyin)) {
|
|
|
+ if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
|
|
|
$childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
- $pinyin = $childCategory->aLIas_pinyin ? $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
|
|
|
+ if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
|
|
|
+ $pinyin = $childCategory->aLIas_pinyin ? $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
}
|
|
|
$article->pinyin = $pinyin;
|
|
|
return $article;
|
|
|
- });
|
|
|
+ });
|
|
|
if (empty($result)) {
|
|
|
return Result::success([]);
|
|
|
}
|
|
@@ -367,17 +371,15 @@ class NewsService implements NewsServiceInterface
|
|
|
->map(function ($article ) use ($data) {
|
|
|
$catid = $article->catid;
|
|
|
$pinyin = '';
|
|
|
- // $category = WebsiteCategory::whereIn('category_id', $catArrId)->where('website_category.website_id', $data['website_id'])->get()->all();
|
|
|
- // if ($catArrId) {
|
|
|
- // foreach ($catArrId as $categoryId) {
|
|
|
- $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
- $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
- if ($category->pid != 0 && !empty($category->aLIas_pinyin)) {
|
|
|
- $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
- $pinyin = $childCategory->aLIas_pinyin ? $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
|
|
|
- }
|
|
|
- // }
|
|
|
- // }
|
|
|
+ $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
+ if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
|
|
|
+ $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
+ if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
|
|
|
+ $pinyin = $childCategory->aLIas_pinyin ? $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
+ }
|
|
|
$article->pinyin = $pinyin;
|
|
|
return $article;
|
|
|
});
|