This commit is contained in:
2021-01-19 15:46:29 +08:00
parent 3894209c63
commit 4e6110cdc0
6 changed files with 32 additions and 25 deletions

View File

@@ -69,6 +69,8 @@ class ArticleController extends AdminController
'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
];
$form->text('url', '外链地址')->help('必须有http');
$form->switch('status', '状态')->states($states);
return $form;

View File

@@ -125,16 +125,16 @@ class IndexController extends AdminController
$form->saving(function (Form $form) {
if (request()->has('title')) {
if (request()->type == Category::TYPE_SHOW && empty(request()->article_id)) {
$error = new MessageBag([
'title' => '错误',
'message' => '文章类型是文章详情的时候需要选择关联文章',
]);
return back()->withInput()->with(compact('error'));
}
}
// if (request()->has('title')) {
// if (request()->type == Category::TYPE_SHOW && empty(request()->article_id)) {
// $error = new MessageBag([
// 'title' => '错误',
// 'message' => '文章类型是文章详情的时候需要选择关联文章',
// ]);
//
// return back()->withInput()->with(compact('error'));
// }
// }
});

View File

@@ -21,6 +21,10 @@ class ArticleController extends Controller
public function show(Article $article)
{
if ($article->url) {
return redirect($article->url);
}
$category = $article->category;
return view('articles.show', compact('article', 'category'));

View File

@@ -16,47 +16,49 @@ class IndexController extends Controller
*/
public function index()
{
$ssp = ArticlePicture::orderBy('sort', 'desc')->where('category_id', 6)->take(3)->get();
//随手拍
$all_articles = Article::orderBy('sort', 'desc')
$ssp = ArticlePicture::orderBy('sort', 'desc')->where('category_id', 6)->take(3)->get();
//最新资讯
$all_articles = Article::latest()
->whereNotIn('category_id', [20, 21, 22])
->take(7)
->get();
//最新资讯
// dd($all_articles->toArray());
//单位概况
$danwei = Article::where('category_id', 15)
->latest()
->first();
//单位概况
//养生保健
$ysbj = Article::where('category_id', 12)
->latest()
->take(3)
->get();
//养生保健
//调研与分析
$dcyfx = Article::where('category_id', 10)
->latest()
->take(7)
->get();
//调研与分析
//应用基础研究
$yyjcyj = Article::where('category_id', 9)
->latest()
->take(7)
->get();
//应用基础研究
//技术研讨
$jsyt = Article::where('category_id', 11)
->latest()
->take(7)
->get();
//技术研讨
//科研与应用
$kyyyy = Article::where('category_id', 12)
->latest()
->take(7)
->get();
//科研与应用
//全科医学
$qkys = Article::where('category_id', 13)
->latest()
->take(7)
->get();
//全科医学
$center_advert = Advert::where('category_id', 18)->first();
//期刊
$qikan_advert = ArticlePicture::latest()->take(4)->where('category_id', 23)->get();

View File

@@ -1,4 +1,4 @@
@charset "utf-8";
@charset "utf-8";
/* CSS Document */
*{ margin:0; padding:0}
ul li{ list-style:none}
@@ -187,7 +187,6 @@ ul.listul li .newsr .more{color:#ff6600;display: inline-block;margin-top: 20px;}
.detailbox .xq .date{color: #999;background: #eee;padding: 8px 0;text-align: center;margin-bottom: 20px;font-size: 14px;}
.detailbox .xq .con{ font-size:14px; color:#333;line-height: 2; padding-bottom:40px}
.detailbox .xq .pprooimg{ display:block; margin:0 auto; max-width:600px; margin-bottom:20px}
.detailbox .xq .con p{ text-indent:2em}
.pagebox{ text-align:center; padding-top:30px; padding-bottom:50px}