This commit is contained in:
2020-09-17 08:58:40 +08:00
parent 1f6ddc1993
commit b266a81b29
6 changed files with 38 additions and 26 deletions

View File

@@ -32,6 +32,11 @@ class IndexController extends AdminController
$grid->column('cover', '封面图片')->image('', 100);
$grid->column('category.title', '所属分类');
$grid->column('title', '文章标题');
$states = [
'on' => ['value' => 1, 'text' => '打开', 'color' => 'primary'],
'off' => ['value' => 2, 'text' => '关闭', 'color' => 'default'],
];
$grid->column('status', '状态')->switch($states);
$grid->column('sort', '序号');
$grid->column('created_at', '创建时间');
@@ -44,20 +49,26 @@ class IndexController extends AdminController
$form->text('title', '文章标题')->rules('min:2');
$form->select('category_id', '所属分类')
->options(Category::selectOptions(function ($model) {
return $model->where('status', 1)->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]);
}, '选择分类'))
->rules('required|min:1', [
'required' => '必须选择所属分类',
'min' => '必须选择所属分类',
]);
->options(Category::selectOptions(function ($model) {
return $model->where('status', 1)->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]);
}, '选择分类'))
->rules('required|min:1', [
'required' => '必须选择所属分类',
'min' => '必须选择所属分类',
]);
$form->textarea('description', '内容简介');
$form->image('cover', '封面')
->move('images/' . date('Y/m/d'))
->removable()
->uniqueName();
->move('images/' . date('Y/m/d'))
->removable()
->uniqueName();
$form->ueditor('content', '文章内容')->rules('required', ['required' => '详情不能为空']);
$form->number('sort', '序号')->default(0)->rules('required', ['required' => '序号必须填写'])->help('倒序优先');
$states = [
'on' => ['value' => 1, 'text' => '打开', 'color' => 'success'],
'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
];
$form->switch('status', '状态')->states($states)->default(1);
return $form;
}

View File

@@ -18,7 +18,7 @@ class CategoryController extends Controller
if ($category->type == Category::TYPE_SHOW && $category->article_id) {
return redirect("articles/" . $category->article_id);
} else {
$articles = $category->relations(Category::TYPE_ARTICLE)->paginate(2);
$articles = $category->relations(Category::TYPE_ARTICLE)->paginate();
$parent = $category;
if ($parent->childrens->isEmpty()) {
$parent = $category->parent;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 KiB

After

Width:  |  Height:  |  Size: 484 KiB

View File

@@ -43,9 +43,9 @@
<div class="biaoti">{{ $article->title }}</div>
<div class="sshuomign"><span>发布时间:{{ $article->created_at->format('Y-m-d') }}</span></div>
<div class="article_txt">
@if ($article->cover)
<img src="{{ $article->cover_path }}">
@endif
{{-- @if ($article->cover)--}}
{{-- <img src="{{ $article->cover_path }}">--}}
{{-- @endif--}}
{!! $article->content !!}
</div>

View File

@@ -94,7 +94,7 @@
<div class="txt flexcolumn jc_sb" data-href="{{ $info->link }}">
<div>
<div class="title overflow1">{{ $info->title }}</div>
<div class="overflow4 "> {{ $info->descrition }}</div>
<div class="overflow4 "> {{ $info->description }}</div>
</div>
<div class="flexrow getMore">查看更多 <img src="/assets/index/images/right.png"></div>
</div>
@@ -104,7 +104,7 @@
<div class="txt flexcolumn jc_sb" data-href="{{ $info->link }}">
<div>
<div class="title overflow1">{{ $info->title }}</div>
<div class="overflow4 "> {{ $info->descrition }}</div>
<div class="overflow4 "> {{ $info->description }}</div>
</div>
<div class="flexrow getMore">查看更多 <img src="/assets/index/images/right.png"></div>
</div>
@@ -126,32 +126,33 @@
<span><a href="{{ getOneCategory(43,'link') }}">更多 >></a></span>
</div>
<div class="words11_zzgz_xfgz_content">
@if (getArticlesBYCate(43,10,'all')->isNotEmpty())
@if (getArticlesBYCate(43,6,'all')->isNotEmpty())
<div class="box">
<div class="focus" style="width: 100%; height: 160px; margin: 0 0 10px">
@foreach (getArticlesBYCate(43,8,'all') as $article)
@foreach (getArticlesBYCate(43,6,'all') as $article)
@if ($loop->iteration<=2)
<img src="{{ $article->cover_path }}" style="width: calc(50% - 5px); height: 100%; margin-right: 5px">
<img data-href="{{ $article->link }}" src="{{ $article->cover_path }}" style="width: calc(50% - 5px); height: 100%; margin-right: 5px">
@endif
@endforeach
</div>
<div class="tem">
<ul>
@foreach (getArticlesBYCate(43,8,'all') as $article)
@if ($loop->iteration>2&&$loop->iteration<6)
@foreach (getArticlesBYCate(43,6,'all') as $article)
@if ($loop->iteration<=3)
<li>
<a href=""><img src="{{ $article->cover_path }}">{{ $article->title }}
<a href="{{ $article->link }}">
<img src="/assets/index/images/icon.png">{{ $article->title }}
</a>
</li>
@endif
@endforeach
</ul>
<ul>
@foreach (getArticlesBYCate(43,8,'all') as $article)
@if ($loop->iteration >5)
@foreach (getArticlesBYCate(43,6,'all') as $article)
@if ($loop->iteration >3)
<li>
<a href=""><img src="{{ $article->cover_path }}">{{ $article->title }}
<a href="{{ $article->link }}">
<img src="/assets/index/images/icon.png">{{ $article->title }}
</a>
</li>
@endif