type == Category::TYPE_SHOW && $category->article_id) { return redirect("articles/" . $category->article_id); } else { $template = 'show'; if ($category->template) { $template = $category->template; } $articles = $category->relations(Category::TYPE_ARTICLE) ->where('status', 1) ->latest('sort') ->latest('created_at') ->paginate(8); $parent = $category; if ($category->childrens->isEmpty() && $category->parent) { $parent = $category->parent; } return view('category.' . $template, compact('articles', 'category', 'parent')); } } }