diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index f5d197e..8a8ea13 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -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; } diff --git a/app/Models/Category.php b/app/Models/Category.php index 506fa80..d79d62f 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -74,4 +74,15 @@ class Category extends Model return $ids; } + public function getTop() + { + $parent = $this; + + while ($parent->parent_id) { + $parent->parent; + } + + return $parent; + } + } diff --git a/resources/views/article/search.blade.php b/resources/views/article/search.blade.php index 85eee58..763957c 100644 --- a/resources/views/article/search.blade.php +++ b/resources/views/article/search.blade.php @@ -1,45 +1,45 @@ -@extends('layouts.app') - -@section('title', '搜索结果') - - -@section('content') - - -
- -
- - -
- @if ($articles->isNotEmpty()) - {{ $articles->appends(['title'=>request()->title])->links('layouts.pagination') }} - @endif -
-
-
- - -@endsection +@extends('layouts.app') + +@section('title', '搜索结果') + + +@section('content') + + +
+ +
+ + +
+ @if ($articles->isNotEmpty()) + {{ $articles->appends(request()->all())->links('layouts.pagination') }} + @endif +
+
+
+ + +@endsection diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index ded7c6d..f1f0b66 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -253,7 +253,7 @@
{{ getOneCategory(18,'title') }} /  {{ getOneCategory(18,'description') }} - 更多 + 更多