From 77d0d9ae92d213eb228657a626eea6d9f692573a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E5=B0=98?= <122383162@qq.com> Date: Wed, 3 Feb 2021 13:41:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Helpers/function.php | 23 ++++ resources/views/articles/index.blade.php | 73 ++++++----- resources/views/category/cgzh.blade.php | 15 +-- resources/views/category/djkxwh.blade.php | 18 +-- resources/views/category/gjzczj.blade.php | 9 +- resources/views/category/jgsz.blade.php | 7 +- resources/views/category/kxyj.blade.php | 128 +------------------ resources/views/category/list.blade.php | 9 +- resources/views/category/rcdw.blade.php | 9 +- resources/views/category/zzjg.blade.php | 18 +-- resources/views/index/index.blade.php | 44 ++++--- resources/views/layouts/navigation.blade.php | 8 ++ 12 files changed, 130 insertions(+), 231 deletions(-) create mode 100644 resources/views/layouts/navigation.blade.php diff --git a/app/Helpers/function.php b/app/Helpers/function.php index 2379e5b..19ddb8d 100644 --- a/app/Helpers/function.php +++ b/app/Helpers/function.php @@ -6,6 +6,7 @@ use App\Models\Article; use App\Models\Patent; use App\Models\Talent; use Encore\Admin\Auth\Database\Menu; +use Illuminate\Support\Arr; function getOneCategory($categoryId, $return = '') { @@ -134,3 +135,25 @@ function getCate($id, $value = '') return $info; } + +/** + * Notes: 获取所有上级 + * @Author: 玄尘 + * @Date : 2021/2/3 13:22 + * @param $categoryId + * @return mixed + */ +function getAllParentCate($categoryId): array +{ + $res = collect(); + $parent = Category::find($categoryId); + $res->prepend($parent); + + while ($parent->parent_id != 0) { + $parent = $parent->parent; + $res->prepend($parent); + } + + return $res->all(); + +} diff --git a/resources/views/articles/index.blade.php b/resources/views/articles/index.blade.php index 090a437..bf4d81d 100644 --- a/resources/views/articles/index.blade.php +++ b/resources/views/articles/index.blade.php @@ -5,45 +5,48 @@ @section('description', $category->description) @section('css') - + @endsection @section('content') -
-
- @include('layouts.left') -
-
-

{{ $category->title }}

-
首页 > {{ $category->title }} >
+
+
+ @include('layouts.left') +
+
+

{{ $category->title }}

+
首页 > {{ $category->title }} >
+
+
    + @foreach($articles as $article) +
  • cover)) class="noImg" @endif> +
    + + + +
    +
    + {{ $article->title }} +
    +
    {{ $article->description }}
    + {{-- 查看更多>> --}} + {{ $article->created_at }} +
    +
  • + @endforeach +
+
+ {{ $articles->links() }} +
+
+
-
    - @foreach($articles as $article) -
  • cover)) class="noImg" @endif> -
    - -
    -
    - {{ $article->title }} -
    -
    {{ $article->description }}
    - {{-- 查看更多>> --}} - {{ $article->created_at }} -
    -
  • - @endforeach -
- {{ $articles->links() }} -
-
-
-
-
@endsection diff --git a/resources/views/category/cgzh.blade.php b/resources/views/category/cgzh.blade.php index c5d7c14..6688b21 100644 --- a/resources/views/category/cgzh.blade.php +++ b/resources/views/category/cgzh.blade.php @@ -11,12 +11,9 @@
- - + @include('layouts.navigation',['category'=>$category]) + +
{{ getOneCategory(20,'title') }} 更多 @@ -25,7 +22,8 @@ @if(getArticlesBYCate(20,8)->isNotEmpty()) @foreach (getArticlesBYCate(20,8) as $article) @if ($loop->first) - + {{ $article->title }} @endif @@ -54,7 +52,8 @@ @if(getArticlesBYCate(21,8)->isNotEmpty()) @foreach (getArticlesBYCate(21,8) as $article) @if ($loop->first) - + {{ $article->title }} @endif diff --git a/resources/views/category/djkxwh.blade.php b/resources/views/category/djkxwh.blade.php index 886001d..350300c 100644 --- a/resources/views/category/djkxwh.blade.php +++ b/resources/views/category/djkxwh.blade.php @@ -11,12 +11,9 @@
- - + @include('layouts.navigation',['category'=>$category]) + +
{{ getOneCategory(32,'title') }} 更多 @@ -25,7 +22,8 @@ @if(getArticlesBYCate(32,8)->isNotEmpty()) @foreach (getArticlesBYCate(32,8) as $article) @if ($loop->first) - + {{ $article->title }} @endif @@ -54,7 +52,8 @@ @if(getArticlesBYCate(33,8)->isNotEmpty()) @foreach (getArticlesBYCate(33,8) as $article) @if ($loop->first) - + {{ $article->title }} @endif @@ -83,7 +82,8 @@ @if(getArticlesBYCate(34,8)->isNotEmpty()) @foreach (getArticlesBYCate(34,8) as $article) @if ($loop->first) - + {{ $article->title }} @endif diff --git a/resources/views/category/gjzczj.blade.php b/resources/views/category/gjzczj.blade.php index 65cbdbf..d314794 100644 --- a/resources/views/category/gjzczj.blade.php +++ b/resources/views/category/gjzczj.blade.php @@ -11,12 +11,9 @@
- - + @include('layouts.navigation',['category'=>$category]) + +
diff --git a/resources/views/category/jgsz.blade.php b/resources/views/category/jgsz.blade.php index fcb3c23..5d2bc2f 100644 --- a/resources/views/category/jgsz.blade.php +++ b/resources/views/category/jgsz.blade.php @@ -11,11 +11,8 @@
- + @include('layouts.navigation',['category'=>$category]) +
{{ getOneCategory(5,'title') }} {{ getOneCategory(6,'title') }} diff --git a/resources/views/category/kxyj.blade.php b/resources/views/category/kxyj.blade.php index 156811f..90f935d 100644 --- a/resources/views/category/kxyj.blade.php +++ b/resources/views/category/kxyj.blade.php @@ -16,36 +16,7 @@ {{ $category->title }}
- {{-- --}} - {{--
--}} - {{-- {{ getOneCategory(11,'title') }}--}} - {{-- 更多--}} - {{--
--}} - {{--
--}} - {{-- @if(getArticlesBYCate(11,8)->isNotEmpty())--}} - {{-- @foreach (getArticlesBYCate(11,8) as $article)--}} - {{-- @if ($loop->first)--}} - {{-- --}} - {{-- {{ $article->title }}--}} - {{-- --}} - {{-- @endif--}} - {{-- @endforeach--}} - {{-- --}} - {{-- @endif--}} - {{--
--}} - +
{{ getOneCategory(13,'title') }} 更多 @@ -91,7 +62,7 @@
    @foreach (getArticlesBYCate(54,8) as $article)
  • - {{ $article->title }} + {{ $article->title }}
  • @endforeach
@@ -101,101 +72,6 @@
- {{-- --}} - {{--
--}} - {{-- 科研进展--}} - {{-- 更多--}} - {{--
--}} - {{--
--}} - {{-- --}} - {{-- --}} - {{--
--}}
diff --git a/resources/views/category/list.blade.php b/resources/views/category/list.blade.php index b1849a9..c4b8196 100644 --- a/resources/views/category/list.blade.php +++ b/resources/views/category/list.blade.php @@ -22,12 +22,9 @@
- - + @include('layouts.navigation',['category'=>$category]) + +
    @if ($articles->isNotEmpty()) @foreach ($articles as $article) diff --git a/resources/views/category/rcdw.blade.php b/resources/views/category/rcdw.blade.php index acb5923..57f694c 100644 --- a/resources/views/category/rcdw.blade.php +++ b/resources/views/category/rcdw.blade.php @@ -11,12 +11,9 @@
    - - + @include('layouts.navigation',['category'=>$category]) + +
    {{ getOneCategory(29,'title') }}
    diff --git a/resources/views/category/zzjg.blade.php b/resources/views/category/zzjg.blade.php index 629b19f..8fcd683 100644 --- a/resources/views/category/zzjg.blade.php +++ b/resources/views/category/zzjg.blade.php @@ -11,17 +11,15 @@
    - - + @include('layouts.navigation',['category'=>$category]) + +
    {{ getOneCategory(2,'title') }}
    -
    +
    {{ getOneArticleBYCate(2)->description }}
    @@ -37,7 +35,8 @@ @if (getArticlesBYCate(3,6)->isNotEmpty()) @foreach (getArticlesBYCate(3,6) as $article)
  • - + {{ $article->title }}

    {{ $article->job }}

    {{ $article->working }}

    @@ -85,7 +84,8 @@ {{ getOneCategory(50,'title') }}
  • -
    +
    {{ getOneArticleBYCate(50,'description') }}
    diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index ef0d287..b30c153 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -4,9 +4,9 @@ @section('content') - + {{-- --}}
    @@ -48,13 +48,13 @@
    @endif @@ -77,13 +77,13 @@
    @endif @@ -117,8 +117,10 @@ @@ -152,8 +154,8 @@ > {{-- {{ $ysxw_right_advert->title }}--}} - @endif - + @endif +
    @if ($kjcg_right_advert->isNotEmpty()) @foreach ($kjcg_right_advert as $advert) diff --git a/resources/views/layouts/navigation.blade.php b/resources/views/layouts/navigation.blade.php new file mode 100644 index 0000000..c3e611e --- /dev/null +++ b/resources/views/layouts/navigation.blade.php @@ -0,0 +1,8 @@ +
    + 首页 + + @foreach(getAllParentCate($category->id) as $cate) + + {{ $cate->title }} + @endforeach +
    \ No newline at end of file