diff --git a/app/Admin/Controllers/Article/IndexController.php b/app/Admin/Controllers/Article/IndexController.php index 3471ac4..f8a78c3 100644 --- a/app/Admin/Controllers/Article/IndexController.php +++ b/app/Admin/Controllers/Article/IndexController.php @@ -34,13 +34,13 @@ class IndexController extends AdminController $grid->column('id', '#ID#'); $grid->column('cover', '封面图片')->image('', 100); $grid->column('category.title', '所属分类'); - $grid->column('category_old.title', '所属老分类'); $grid->column('title', '文章标题'); $states = [ 'on' => ['value' => 1, 'text' => '打开', 'color' => 'primary'], 'off' => ['value' => 2, 'text' => '关闭', 'color' => 'default'], ]; $grid->column('status', '状态')->switch($states); + $grid->column('recommen', '推荐')->switch(); $grid->column('sort', '序号'); $grid->column('created_at', '创建时间'); @@ -63,6 +63,10 @@ class IndexController extends AdminController ->move('images/' . date('Y/m/d')) ->removable() ->uniqueName(); + $form->image('logo', 'logo') + ->move('images/' . date('Y/m/d')) + ->removable() + ->uniqueName(); $form->ueditor('content', '文章内容')->rules('required', ['required' => '详情不能为空']); $form->number('sort', '序号')->default(0)->rules('required', ['required' => '序号必须填写'])->help('倒序优先'); $states = [ @@ -71,6 +75,7 @@ class IndexController extends AdminController ]; $form->datetime('created_at', '发布时间'); $form->switch('status', '状态')->states($states)->default(1); + $form->switch('recommen', '推荐')->default(0); return $form; } diff --git a/app/Admin/Controllers/Category/IndexController.php b/app/Admin/Controllers/Category/IndexController.php index 22162ef..ca5c6f1 100644 --- a/app/Admin/Controllers/Category/IndexController.php +++ b/app/Admin/Controllers/Category/IndexController.php @@ -44,6 +44,9 @@ class IndexController extends AdminController })->pluck('title', 'id'); })->help('当分类类型是文章详情的时候需要选择关联文章'); }) + ->when(Category::TYPE_LINK, function (WidgetsForm $form) { + $form->text('url', '跳转地址'); + }) ->required(); $form->textarea('description', '分类简介') ->rules('nullable'); @@ -114,6 +117,9 @@ class IndexController extends AdminController })->pluck('title', 'id'); })->help('当分类类型是文章详情的时候需要选择关联文章'); }) + ->when(Category::TYPE_LINK, function (Form $form) { + $form->text('url', '跳转地址'); + }) ->required() ->rules('required'); $form->textarea('description', '分类简介')->rows(4)->rules('nullable'); diff --git a/app/Admin/Controllers/Video/IndexController.php b/app/Admin/Controllers/Video/IndexController.php index 9e59945..4fe5764 100644 --- a/app/Admin/Controllers/Video/IndexController.php +++ b/app/Admin/Controllers/Video/IndexController.php @@ -31,9 +31,9 @@ class IndexController extends AdminController $grid->column('id'); $grid->column('title', '视频名称'); - $grid->column('cover', '视频地址')->downloadable(); + $grid->column('cover', '封面')->image(); + $grid->column('link', '视频地址')->downloadable(); $grid->column('category.title', '分类名称'); - $grid->column('url', '地址'); $grid->column('sort', '排序'); return $grid; @@ -60,7 +60,20 @@ class IndexController extends AdminController 'required' => '必须选择所属分类', 'min' => '必须选择所属分类', ]); - $form->file('cover', '视频') + + $form->file('cover', '封面') + ->rules(function ($form) { + if ($form->model()->cover != []) { + return 'nullable|image'; + } else { + return 'required'; + } + }) + ->move('images/' . date('Y/m/d')) + ->removable() + ->uniqueName(); + + $form->file('link', '视频') ->rules(function ($form) { if ($form->model()->cover != []) { return 'nullable|image'; @@ -71,7 +84,7 @@ class IndexController extends AdminController ->move('videos/' . date('Y/m/d')) ->removable() ->uniqueName(); - $form->text('url', '链接地址'); + $form->number('sort', '排序') ->default(1) ->required() diff --git a/app/Helpers/function.php b/app/Helpers/function.php index 972feb1..30c7bbf 100644 --- a/app/Helpers/function.php +++ b/app/Helpers/function.php @@ -52,39 +52,36 @@ function getOneArticleBYCate($categoryId, $result = '') * @Date : 2020/9/10 10:05 * @param $categoryId * @param int $take - * @param string $mark + * @param int $recommen * @return \App\Models\Article */ -function getArticlesBYCate($categoryId, $take = 8, $mark = 'one') +function getArticlesBYCate($categoryId, $take = 8, $recommen = 0) { - if ($mark == 'one') { - $articles = Article::where('status', 1) - ->ByCategory($categoryId) - ->latest('sort') - ->latest() - ->take($take) - ->get(); - } else { - $cate = Category::find($categoryId); - $ids = $cate ? $cate->getAllChildrenId() : []; + $cate = Category::find($categoryId); + $ids = $cate ? $cate->getAllChildrenId() : []; - $articles = Article::where('status', 1) - ->ByCategory($ids) - ->latest('sort') - ->latest() - ->take($take) - ->get(); - } + $articles = Article::where('status', 1) + ->ByCategory([$categoryId]) + ->latest('sort') + ->latest() + ->when($recommen, function ($q) use ($recommen) { + $q->where('recommen', 1); + }) + ->take($take) + ->get(); return $articles; } //获取子分类 -function getCateChild($categoryId) +function getCateChild($categoryId, $take = '') { return Category::where('status', 1) ->where('parent_id', $categoryId) ->orderBy('order', 'desc') + ->when($take, function ($q) use ($take) { + $q->take($take); + }) ->get(); } diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 1a692c1..34d560a 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -18,17 +18,19 @@ class CategoryController extends Controller { if ($category->type == Category::TYPE_SHOW && $category->article_id) { return redirect("articles/" . $category->article_id); + } elseif ($category->type == Category::TYPE_LINK && $category->url) { + return redirect()->away($category->url); } else { $template = 'show'; if ($category->template) { $template = $category->template; } - $articles = $category->relations(Category::TYPE_ARTICLE) + $articles = $category->relations($category->type) ->where('status', 1) ->latest('sort') ->latest('created_at') - ->paginate(8); + ->paginate(); $parent = $category; if ($category->childrens->isEmpty() && $category->parent) { diff --git a/app/Models/Article.php b/app/Models/Article.php index 0dec20c..af69bfc 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -17,6 +17,11 @@ class Article extends Model return route('article.show', $this); } + public function getLogoUrlAttribute(): string + { + return $this->parseImageUrl($this->logo); + } + /*** * Notes: 获取详情内图片 * @Author: 玄尘 diff --git a/app/Models/Category.php b/app/Models/Category.php index 9b23578..ac35af1 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -18,11 +18,13 @@ class Category extends Model public const TYPE_ARTICLE = 'article'; public const TYPE_ADVERT = 'advert'; public const TYPE_VIDEO = 'video'; + public const TYPE_LINK = 'link'; public const TYPES = [ self::TYPE_ARTICLE => '文章列表', self::TYPE_SHOW => '文章详情', self::TYPE_ADVERT => '图片列表', self::TYPE_VIDEO => '视频列表', + self::TYPE_LINK => '跳转链接', ]; public $cover_field = 'cover'; @@ -48,7 +50,8 @@ class Category extends Model return $this->hasOne(Article::class)->where('id', $this->article_id); break; case self::TYPE_ARTICLE: - return $this->belongsToMany(Article::class); + // return $this->belongsToMany(Article::class); + return $this->hasMany(Article::class); break; case self::TYPE_ADVERT: return $this->hasMany(Advert::class); @@ -85,13 +88,14 @@ class Category extends Model public function getAllChildrenId(): array { $ids = array_keys($this->buildSelectOptions([], $this->id)); + if ($ids) { array_unshift($ids, $this->id); return $ids; } - return []; + return [$this->id]; } // public function articles(): BelongsToMany diff --git a/app/Models/Video.php b/app/Models/Video.php index bd18f75..3be6534 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -10,4 +10,9 @@ class Video extends Model use HasCovers, BelongsToCategory; + + public function getLogoUrlAttribute(): string + { + return $this->parseImageUrl($this->logo); + } } diff --git a/public/assets/index/css/style.css b/public/assets/index/css/style.css index 9f3224c..c8c5229 100644 --- a/public/assets/index/css/style.css +++ b/public/assets/index/css/style.css @@ -308,7 +308,7 @@ body { top: 2px; width: 14px; height: 14px; - background: url(../image/indexIcon/indexNew_row.png) center no-repeat; + background: url(/assets/index/images/indexIcon/indexNew_row.png) center no-repeat; } .indexNew-list li .indexNew-name { @@ -643,7 +643,7 @@ body { .modularServe-label { cursor: pointer; - background: url(../image/titleTem_back.png) no-repeat center; + background: url(/assets/index/images/titleTem_back.png) no-repeat center; background-size: cover; width: 100%; padding: 40px 20px 20px; @@ -695,7 +695,7 @@ body { top: 4px; width: 15px; height: 15px; - background: url(../image/indexIcon/indexNew_row.png) center no-repeat; + background: url(/assets/index/images/indexIcon/indexNew_row.png) center no-repeat; background-size: 100% 100%; } diff --git a/resources/views/category/djwh.blade.php b/resources/views/category/djwh.blade.php index b88d0ba..585797e 100644 --- a/resources/views/category/djwh.blade.php +++ b/resources/views/category/djwh.blade.php @@ -18,7 +18,7 @@
{{ getOneCategory(60,'title') }} -
更多>>
+
更多>>
@if (getArticlesBYCate(60,3)->isNotEmpty()) @@ -48,7 +48,7 @@
{{ getOneCategory(61,'title') }} -
更多>>
+
更多>>
@if (getArticlesBYCate(61,3)->isNotEmpty()) @@ -110,7 +110,8 @@
diff --git a/resources/views/category/jianjie.blade.php b/resources/views/category/jianjie.blade.php index 2e3983f..21cc567 100644 --- a/resources/views/category/jianjie.blade.php +++ b/resources/views/category/jianjie.blade.php @@ -171,12 +171,14 @@
- + @if (getAdvertsByCate(16,10)->isNotEmpty())
diff --git a/resources/views/category/kxjs_rcdw.blade.php b/resources/views/category/kxjs_rcdw.blade.php index 23ca74a..6587016 100644 --- a/resources/views/category/kxjs_rcdw.blade.php +++ b/resources/views/category/kxjs_rcdw.blade.php @@ -100,7 +100,6 @@
- @if(getCateChild(42)->isNotEmpty()) @foreach(getCateChild(42) as $cate)
@@ -128,7 +127,7 @@ @if (getArticlesBYCate(43,6)->isNotEmpty()) @foreach (getArticlesBYCate(43,6) as $info)
-
+
diff --git a/resources/views/category/kxyj.blade.php b/resources/views/category/kxyj.blade.php index be79bc2..56337c7 100644 --- a/resources/views/category/kxyj.blade.php +++ b/resources/views/category/kxyj.blade.php @@ -354,8 +354,8 @@
@if(getVideoByCate(29)) 首页 > - {{ $parent->title }} + {{ $category->title }}
diff --git a/resources/views/category/videos.blade.php b/resources/views/category/videos.blade.php index a6bbba3..3ae78c1 100644 --- a/resources/views/category/videos.blade.php +++ b/resources/views/category/videos.blade.php @@ -2,6 +2,11 @@ @section('title', $parent->title) + +@section('css') + +@endsection + @section('content') @include('category.navigation') @@ -12,12 +17,44 @@ @include('category.left') -
-
- 视频列表 + @if ($articles->isNotEmpty()) +
+
+
+ @foreach ($articles as $article) +
+
+
+ + +
+
+

{{ $article->title }}

+
+
+
+ @endforeach +
+
+
+ @if ($articles->isNotEmpty()) + {{ $articles->links('layouts.pagination') }} + @endif +
-
+ @else +
+
+ + 抱歉,暂无内容 +
+
+ @endif
@endsection - +@push('script') + +@endpush diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index e37cbc7..1e3149d 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -12,101 +12,73 @@
-
-
- + @if (getArticlesBYCate(66,7)->isNotEmpty()) +
+
+ +
-
-
-
    -
  • -
    - 一站式1人才招聘 面试结果公示2020.06.21 -
    -
    - 黑龙江省科学院2020年生物学专业硕士研究生黑龙江省科学院2020年生物学专业硕士研究生 -
    -
  • -
  • -
    - 黑龙江省科学院 2020年招收硕士研究生调剂需求2020.06.21 -
    -
    - 黑龙江省科学院2020年生物学专业硕士研究生黑龙江省科学院2020年生物学专业硕士研究生 -
    -
  • -
  • -
    - 学术讲座通知2020.06.21 -
    -
    - 黑龙江省科学院2020年生物学专业硕士研究生黑龙江省科学院2020年生物学专业硕士研究生 -
    -
  • -
  • -
    - 国务院办公厅关于推进养老服务发展的意见2020.06.21 -
    -
    - 黑龙江省科学院2020年生物学专业硕士研究生黑龙江省科学院2020年生物学专业硕士研究生 -
    -
  • -
  • -
    - 《关于统筹推进自然资源资产产权制度改革的指导意见》2020.06.21 -
    -
    - 黑龙江省科学院2020年生物学专业硕士研究生黑龙江省科学院2020年生物学专业硕士研究生 -
    -
  • -
  • -
    - 《资源资产产权制度》2020.06.21 -
    -
    - 黑龙江省科学院2020年生物学专业硕士研究生黑龙江省科学院2020年生物学专业硕士研究生 -
    -
  • -
-
+
+
    + @foreach (getArticlesBYCate(66,7) as $info) +
  • +
    + {{ $info->title }}{{ $info->created_at->toDateString() }} +
    +
    + {{ $info->description }} +
    +
  • + @endforeach +
+
+ @endif
-
-
- + @if (getArticlesBYCate(67,7)->isNotEmpty()) +
+
+ +
-
-
-
    -
  • -
    - 通知公告2020.06.21 -
    -
    - 黑龙江省科学院2020年生物学专业硕士研究生黑龙江省科学院2020年生物学专业硕士研究生 -
    -
  • -
-
+
+
    + @foreach (getArticlesBYCate(67,7) as $info) +
  • +
    + {{ $info->title }}{{ $info->created_at->toDateString() }} +
    +
    + {{ $info->description }} +
    +
  • + @endforeach +
+
+ @endif
@@ -153,67 +125,17 @@
-
-
- - -
-
湿地全球变化生态
-
-
-
- -
-
寒温带森林生物多样性
-
-
-
- -
-
生态保护与恢复
-
-
-
- -
-
特色观赏植物培育与利用
-
-
-
- -
-
特色经济植物与利用
-
-
-
- -
-
湿地全球变化生态
-
-
-
- -
-
寒温带森林生物多样性
-
-
-
- -
-
生态保护与恢复
-
-
-
- -
-
特色观赏植物培育与利用
-
-
-
- -
-
特色经济植物与利用
-
+ @if (getArticlesBYCate(18,10)->isNotEmpty()) + @foreach (getArticlesBYCate(18,10) as $info) +
+
+ + +
+
{{ $info->title }}
+
+ @endforeach + @endif
@@ -231,46 +153,24 @@
-
-
-
植物学科
-
-
- - -
-
- 2002年4月11日上午,建投集团大数据公司、哈尔滨工程大学计算机学院、省科学院智能制造研 + @if (getArticlesBYCate(31,3)->isNotEmpty()) + @foreach (getArticlesBYCate(31,3) as $info) +
+
+
{{ $info->title }}
+
+
+ + +
+
+ {{ $info->description }} +
+
-
-
-
-
-
生态学科
-
-
- -
-
- 2002年4月11日上午,建投集团大数据公司、哈尔滨工程大学计算机学院、省科学院智能制造研 -
-
-
-
-
-
-
园林植物学科
-
-
- -
-
- 2002年4月11日上午,建投集团大数据公司、哈尔滨工程大学计算机学院、省科学院智能制造研 -
-
-
-
+ @endforeach + @endif
@@ -288,46 +188,24 @@
-
-
-
区域地理学
-
-
- - -
-
- 2002年4月11日上午,建投集团大数据公司、哈尔滨工程大学计算机学院、省科学院智能制造研 + @if (getArticlesBYCate(32,3)->isNotEmpty()) + @foreach (getArticlesBYCate(32,3) as $info) +
+
+
{{ $info->title }}
+
+
+ + +
+
+ {{ $info->description }} +
+
-
-
-
-
-
野生动物保护与利用学科
-
-
- -
-
- 2002年4月11日上午,建投集团大数据公司、哈尔滨工程大学计算机学院、省科学院智能制造研 -
-
-
-
-
-
-
火山学科
-
-
- -
-
- 2002年4月11日上午,建投集团大数据公司、哈尔滨工程大学计算机学院、省科学院智能制造研 -
-
-
-
+ @endforeach + @endif
@@ -344,87 +222,35 @@
-
-
- 国际合作平台 -
-
-
-
- - + @if(getCateChild(5,3)->isNotEmpty()) + @foreach(getCateChild(5,3) as $cate) +
+
+ {{ $cate->title }}
-
    -
  • - 联合国教科文组织国际自然与文化遗产空间技术中心哈尔滨分中心 -
  • -
  • - 国际森林生物多样性检测网络寒温带森林样区 -
  • -
  • - 中国-俄罗斯生态联合创新研究中心 -
  • -
-
-
- 查看更多 -
-
-
-
-
- 国家级平台 -
-
-
-
- - +
+
+
+ + +
+
    + @if (getArticlesBYCate($cate->id,3)->isNotEmpty()) + @foreach (getArticlesBYCate($cate->id,3) as $info) +
  • + {{ $info->title }} +
  • + @endforeach + @endif +
+
+
+ 查看更多 +
-
    -
  • - 联合国教科文组织国际自然与文化遗产空间技术中心哈尔滨分中心 -
  • -
  • - 国际森林生物多样性检测网络寒温带森林样区 -
  • -
  • - 中国-俄罗斯生态联合创新研究中心 -
  • -
-
- 查看更多 -
-
-
-
-
- 省级平台 -
-
-
-
- - -
-
    -
  • - 联合国教科文组织国际自然与文化遗产空间技术中心哈尔滨分中心 -
  • -
  • - 国际森林生物多样性检测网络寒温带森林样区 -
  • -
  • - 中国-俄罗斯生态联合创新研究中心 -
  • -
-
-
- 查看更多 -
-
-
+ @endforeach + @endif
@@ -446,7 +272,7 @@
@@ -454,141 +280,35 @@
-
- - -
天然植物功能产物团队
-
-
- - -
寒地花卉创新团队
-
-
- - -
湿地生态与恢复创新团队
-
+ @if (getArticlesBYCate(43,3,1)->isNotEmpty()) + @foreach (getArticlesBYCate(43,3,1) as $info) +
+ + +
{{ $info->title }}
+
+ @endforeach + @endif
-
-
-
- - 湿地生态与恢复 + @if (getArticlesBYCate(43,14)->isNotEmpty()) + @foreach (getArticlesBYCate(43,14) as $info) +
+
+
+ + {{ $info->title }} +
+
-
-
+ @endforeach + @endif
-
- - 湿地植物分子生态 -
-
-
-
-
-
- - 寒温带森林
生物多样性保育
-
-
-
-
-
-
- - 火山植被生
态协同进化
-
-
-
-
-
-
- - 智能生物多样性 -
-
-
-
-
-
- - 特色经济植物 -
-
-
-
-
-
- - 天然植物功能产物 -
-
-
-
-
-
- - 寒地花卉 -
-
-
-
-
-
- - 功能性园林植物 -
-
-
-
-
-
- - 保护动物保育 -
-
-
-
-
-
- - 自然遗产保护 -
-
-
-
-
-
- - 自然资源效应 -
-
-
-
-
-
- - 火山矿泉 -
-
-
-
-
-
- - 火山矿泥 -
-
-
-
-
-
+
查看更多 >>
@@ -618,11 +338,11 @@
- @if (getArticlesBYCate(74,6)->isNotEmpty()) - @foreach (getArticlesBYCate(74,6) as $info) + @if(getCateChild(42)->isNotEmpty()) + @foreach(getCateChild(42) as $cate)
-
- {{ $info->title }} +
+ {{ $cate->title }}
@endforeach @@ -643,8 +363,8 @@
    @if (getArticlesBYCate(27,5)->isNotEmpty()) - @foreach (getArticlesBYCate(74,5) as $info) -
  • + @foreach (getArticlesBYCate(27,5) as $info) +
  • {{ $info->title }}
    @@ -662,30 +382,16 @@
    -
    -
    -
    国家博士后工作站
    -
    -
    -
    -
    -
    科学传播
    -
    -
    -
    -
    -
    黑龙江省生物多样性
    基础信息系统
    -
    -
    -
    -
    -
    人才招聘
    -
    -
    + @if(getCateChild(68)) + @foreach(getCateChild(68) as $cate) +
    +
    +
    {{ $cate->title }}
    +
    +
    + @endforeach + @endif
    @@ -705,6 +411,13 @@ $('.Rightfixed-img').css("width", "48px"); } ); + + $('.new_list').click(function () { + var link = $(this).data('link'); + + $('.new_list_more').attr('data-href', link) + }); }); + @endpush diff --git a/resources/views/layouts/pagination.blade.php b/resources/views/layouts/pagination.blade.php index d345e76..6a6f064 100644 --- a/resources/views/layouts/pagination.blade.php +++ b/resources/views/layouts/pagination.blade.php @@ -1,43 +1,39 @@ @if ($paginator->hasPages()) -
    -
    - {{-- Previous Page Link --}} - @if ($paginator->onFirstPage()) - 上一页 - @else - 上一页 +
      + @if ($paginator->onFirstPage()) +
    • + @else +
    • + + + +
    • + @endif + @foreach ($elements as $element) + {{-- "Three Dots" Separator --}} + @if (is_string($element)) +
    • + {{ $element }} +
    • @endif - {{-- Pagination Elements --}} - @foreach ($elements as $element) - {{-- "Three Dots" Separator --}} - @if (is_string($element)) -
    • {{ $element }} -
    • - @endif - - {{-- Array Of Links --}} - @if (is_array($element)) - @foreach ($element as $page => $url) - @if ($page == $paginator->currentPage()) - {{ $page }} - @else - {{ $page }} - @endif - @endforeach - @endif - @endforeach - - {{-- Next Page Link --}} - @if ($paginator->hasMorePages()) - 下一页 - @else - 下一页 + {{-- Array Of Links --}} + @if (is_array($element)) + @foreach ($element as $page => $url) + @if ($page == $paginator->currentPage()) +
    • {{ $page }} (current)
    • + @else +
    • {{ $page }}
    • + @endif + @endforeach @endif - {{--
    • --}} - {{-- --}} - {{--
    • --}} + @endforeach + @if ($paginator->hasMorePages()) +
    • + @else +
    • + @endif + +
    -
    -
    @endif