阶段更新

This commit is contained in:
2022-06-30 10:34:16 +08:00
parent 619e493b0e
commit 2ef7d3786d
8 changed files with 111 additions and 71 deletions

View File

@@ -55,14 +55,19 @@ class IndexController extends AdminController
$form->belongsToMany('categories', CategorySelectAble::class, __('关联分类'));
$form->textarea('description', '内容简介');
$form->list('subjoin', '附加')
->help('只有领导班子需要添加');
// $form->list('subjoin', '附加')
// ->help('只有领导班子需要添加');
$form->image('cover', '封面')
->move('images/'.date('Y/m/d'))
->removable()
->uniqueName();
$form->image('label', '图标')
->move('images/'.date('Y/m/d'))
->removable()
->uniqueName();
$form->multipleImage('pictures', '多图')
->move('images/'.date('Y/m/d'))
->removable()

View File

@@ -34,7 +34,7 @@ class CategoryController extends Controller
$parent = $category->parent;
}
$articles = Article::ByCategory($category->getAllChildrenId())
$articles = Article::shown()->ByCategory($category->getAllChildrenId())
->where('status', 1)
->Bysort()
->paginate();
@@ -47,7 +47,7 @@ class CategoryController extends Controller
];
if ($category->id == 2) {
$article = Article::query()->ByCategory(2)->Bysort()->first();
$article = Article::shown()->ByCategory(2)->Bysort()->first();
$data = array_merge($data, [
'article' => $article,
]);
@@ -57,9 +57,9 @@ class CategoryController extends Controller
$cgCate = Category::find(24);
$hjCate = Category::find(20);
$zlCate = Category::find(21);
$cgArticles = Article::query()->ByCategory($cgCate->id)->Bysort()->take(3)->get();
$hjArticles = Article::query()->ByCategory($hjCate->id)->Bysort()->take(3)->get();
$zlArticles = Article::query()->ByCategory($zlCate->id)->Bysort()->take(6)->get();
$cgArticles = Article::shown()->ByCategory($cgCate->id)->Bysort()->take(3)->get();
$hjArticles = Article::shown()->ByCategory($hjCate->id)->Bysort()->take(3)->get();
$zlArticles = Article::shown()->ByCategory($zlCate->id)->Bysort()->take(6)->get();
$data = array_merge($data, [
'cgCate' => $cgCate,
@@ -72,7 +72,7 @@ class CategoryController extends Controller
}
if ($category->id == 3) {
$articles = Article::ByCategory($category->getAllChildrenId())
$articles = Article::shown()->ByCategory($category->getAllChildrenId())
->where('status', 1)
->Bysort()
->get();
@@ -87,9 +87,9 @@ class CategoryController extends Controller
$nyydtCate = Category::find(7);
$mtbdCate = Category::find(31);
$tzArticles = Article::query()->ByCategory($tzCate->id)->Bysort()->take(4)->get();
$nyydtArticles = Article::query()->ByCategory($nyydtCate->id)->Bysort()->take(3)->get();
$mtbdArticles = Article::query()->ByCategory($mtbdCate->id)->Bysort()->take(3)->get();
$tzArticles = Article::shown()->ByCategory($tzCate->id)->Bysort()->take(4)->get();
$nyydtArticles = Article::shown()->ByCategory($nyydtCate->id)->Bysort()->take(3)->get();
$mtbdArticles = Article::shown()->ByCategory($mtbdCate->id)->Bysort()->take(3)->get();
$data = array_merge($data, [
'tzCate' => $tzCate,
'nyydtCate' => $nyydtCate,
@@ -105,8 +105,8 @@ class CategoryController extends Controller
$zdCate = Category::find(16);
$ljCate = Category::find(29);
$yjArticles = Article::query()->ByCategory($yjCate->id)->Bysort()->take(3)->get();
$ljLeaders = Leader::query()->where('category_id', $ljCate->id)->Bysort()->take(3)->get();
$yjArticles = Article::shown()->ByCategory($yjCate->id)->Bysort()->take(3)->get();
$ljLeaders = Leader::shown()->where('category_id', $ljCate->id)->Bysort()->take(3)->get();
$data = array_merge($data, [
'yjCate' => $yjCate,
'zdCate' => $zdCate,
@@ -118,9 +118,14 @@ class CategoryController extends Controller
if ($category->id == 32) {
$nghjxhArticle = Article::query()->ByCategory($category->id)->Bysort()->first();
$data = array_merge($data, [
$nghjxhArticle = Article::shown()->ByCategory($category->id)->Bysort()->first();
$xhdtCate = Category::find(33);
$xhdtArticles = Article::shown()->ByCategory($xhdtCate->id)->Bysort()->get();
$data = array_merge($data, [
'nghjxhArticle' => $nghjxhArticle,
'xhdtCate' => $xhdtCate,
'xhdtArticles' => $xhdtArticles,
]);
}

View File

@@ -22,7 +22,7 @@ class StaffController extends Controller
$parent = $category->parent;
}
$staffs = Staff::query()->latest('order')->get();
$staffs = Staff::shown()->latest('order')->get();
$data = [
'staffs' => $staffs,

View File

@@ -4,12 +4,13 @@ namespace App\Models;
use App\Models\Traits\HasCovers;
use App\Models\Traits\HasSort;
use App\Models\Traits\ScopeStatus;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Article extends Model
{
use HasCovers,HasSort;
use HasCovers, HasSort, ScopeStatus;
/**
* 应进行类型转换的属性
@@ -59,16 +60,40 @@ class Article extends Model
});
}
/**
* Notes: 获取时间 天
*
* @Author: 玄尘
* @Date: 2022/6/30 10:33
* @return mixed
*/
public function getDateD()
{
return $this->created_at->format('d');
}
/**
* Notes: 获取时间 年月
*
* @Author: 玄尘
* @Date: 2022/6/30 10:33
* @return mixed
*/
public function getDateYM()
{
return $this->created_at->format('Y-m');
}
/**
* Notes : 解析单图地址
*
* @Date : 2021/3/16 4:54 下午
* @Author : <Jason.C>
* @return string
*/
public function getLabelUrlAttribute(): string
{
return $this->parseImageUrl($this->label);
}
}

View File

@@ -5,12 +5,14 @@ namespace App\Models;
use App\Models\Traits\BelongsToCategory;
use App\Models\Traits\HasCovers;
use App\Models\Traits\HasSort;
use App\Models\Traits\ScopeStatus;
use Illuminate\Database\Eloquent\Model;
class Leader extends Model
{
use BelongsToCategory,
HasCovers,
ScopeStatus,
HasSort;
const STATUS_FALSE = 0;

View File

@@ -4,10 +4,11 @@ namespace App\Models;
use App\Models\Traits\BelongsToCategory;
use App\Models\Traits\HasCovers;
use App\Models\Traits\ScopeStatus;
class Staff extends Model
{
use BelongsToCategory, HasCovers;
use BelongsToCategory, HasCovers,ScopeStatus;
const STATUS_FALSE = 0;

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Models\Traits;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use function collect;
trait ScopeStatus
{
/**
* Notes: 排序
*
* @Author: 玄尘
* @Date: 2022/6/28 14:49
* @param $query
* @param $ids
* @return mixed
*/
public function scopeShown($query)
{
return $query->where('status',1);
}
}

View File

@@ -35,62 +35,38 @@
<!-- 活动新闻列表 -->
<div class="scientific">
<div class="learnNews">
<div class="learnNews-left" style="background-image: url(./images/learnNews_back.png);">
<div class="learnNews-left-name">活动新闻列表</div>
<div class="learnNews-left-text">Event news</div>
<a href="列表页-有图.html" class="learnNews-left-btn">
<div class="learnNews-left"
style="background-image: url({{ asset('assets/index/images/learnNews_back.png') }});">
<div class="learnNews-left-name">{{ $xhdtCate->title }}</div>
<div class="learnNews-left-text">{{ $xhdtCate->description }}</div>
<a href="{{ $xhdtCate->link }}" class="learnNews-left-btn">
<span>+</span>
<div class="learnNews-left-more">查看更多 &gt;&gt;</div>
</a>
</div>
<div class="learnNews-right">
<ul class="learnList">
<li>
<a href="详情页.html">
<div class="ce-img learnList-img">
<span style="background-image: url(./temporary/img1.png);"></span>
</div>
<div class="learnList-cont">
<div class="nowrap learnList-name">一种硫掺杂催化油浆基多孔碳材料及其制备方法</div>
<div class="learnList-time">发布时间2021-10-28</div>
<div class="ellipsis learnList-text">
一种硫掺杂催化油浆基多孔碳材料及其制备方法,它属于催化裂化油浆综合利用及功能型碳材料领域。本发明要解决的技术问题为当前存在的催化油浆深加工利用问题。
</div>
<div class="learnList-more">了解详情 &gt;</div>
</div>
</a>
</li>
<li>
<a href="详情页.html">
<div class="ce-img learnList-img">
<span style="background-image: url(./temporary/img4.png);"></span>
</div>
<div class="learnList-cont">
<div class="nowrap learnList-name">一种硫掺杂催化油浆基多孔碳材料及其制备方法</div>
<div class="learnList-time">发布时间2021-10-28</div>
<div class="ellipsis learnList-text">
一种硫掺杂催化油浆基多孔碳材料及其制备方法,它属于催化裂化油浆综合利用及功能型碳材料领域。本发明要解决的技术问题为当前存在的催化油浆深加工利用问题。
</div>
<div class="learnList-more">了解详情 &gt;</div>
</div>
</a>
</li>
<li>
<a href="详情页.html">
<div class="ce-img learnList-img">
<span style="background-image: url(./temporary/img3.png);"></span>
</div>
<div class="learnList-cont">
<div class="nowrap learnList-name">一种硫掺杂催化油浆基多孔碳材料及其制备方法</div>
<div class="learnList-time">发布时间2021-10-28</div>
<div class="ellipsis learnList-text">
一种硫掺杂催化油浆基多孔碳材料及其制备方法,它属于催化裂化油浆综合利用及功能型碳材料领域。本发明要解决的技术问题为当前存在的催化油浆深加工利用问题。
</div>
<div class="learnList-more">了解详情 &gt;</div>
</div>
</a>
</li>
</ul>
@if ($xhdtArticles->isNotEmpty())
<ul class="learnList">
@foreach ($xhdtArticles as $relation)
<li>
<a href="{{ $relation->link }}">
<div class="ce-img learnList-img">
<span style="background-image: url({{ $relation->cover_url }});"></span>
</div>
<div class="learnList-cont">
<div class="nowrap learnList-name">{{ $relation->title }}</div>
<div class="learnList-time">
发布时间:{{ $relation->created_at->format('Y-m-d') }}</div>
<div class="ellipsis learnList-text">
{{ $relation->description }}
</div>
<div class="learnList-more">了解详情 &gt;</div>
</div>
</a>
</li>
@endforeach
</ul>
@endif
</div>
</div>
</div>