小调整
This commit is contained in:
@@ -20,7 +20,7 @@ class CategoryController extends Controller
|
||||
} else {
|
||||
$articles = $category->relations(Category::TYPE_ARTICLE)->paginate(8);
|
||||
$parent = $category;
|
||||
if ($category->childrens->isEmpty() && $category->patent) {
|
||||
if ($category->childrens->isEmpty() && $category->parent) {
|
||||
$parent = $category->parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,4 +74,15 @@ class Category extends Model
|
||||
return $ids;
|
||||
}
|
||||
|
||||
public function getTop()
|
||||
{
|
||||
$parent = $this;
|
||||
|
||||
while ($parent->parent_id) {
|
||||
$parent->parent;
|
||||
}
|
||||
|
||||
return $parent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user