diff --git a/app/Http/Controllers/ArticleController.php b/app/Http/Controllers/ArticleController.php index a8ae95e..a874a3e 100644 --- a/app/Http/Controllers/ArticleController.php +++ b/app/Http/Controllers/ArticleController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Models\Advert; use App\Models\Article; +use Illuminate\Http\Request; class ArticleController extends Controller { @@ -27,4 +28,18 @@ class ArticleController extends Controller } + //搜索 + public function search(Request $request) + { + $title = $request->title; + $articles = Article::where('status', 1) + ->when($title, function ($q) use ($title) { + $q->where('title', 'like', "%{$title}%"); + }) + ->paginate(); + + return view('article.search', compact('articles')); + + } + } diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index f9b0aeb..f5d197e 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -20,7 +20,7 @@ class CategoryController extends Controller } else { $articles = $category->relations(Category::TYPE_ARTICLE)->paginate(8); $parent = $category; - if ($category->childrens->isEmpty()) { + if ($category->childrens->isEmpty() && $category->patent) { $parent = $category->parent; } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index c06d017..d328b6b 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -22,7 +22,7 @@ class Controller extends BaseController $categorys = Category::where('status', 1) ->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW]) ->where('top_show', 1) - ->orderBy('order', 'desc') + ->orderBy('order', 'asc') ->select('id', 'title') ->get(); $links = Link::get(); diff --git a/public/assets/index/css/style.css b/public/assets/index/css/style.css index 305c3a8..d29e3a8 100644 --- a/public/assets/index/css/style.css +++ b/public/assets/index/css/style.css @@ -118,7 +118,6 @@ img { background-color: #eff0f4; height: 40px; line-height: 40px; - text-align: right; } .tool a { @@ -135,6 +134,33 @@ img { color: #203175; } +.search { + margin-top: 5px; + width: 20%; + display: flex; + float: right; +} + +.search input { + float: left; + flex: 4; + height: 30px; + outline: none; + border: 1px solid #203175; + box-sizing: border-box; + padding: 0 10px; +} + +.search button { + float: right; + flex: 1; + height: 30px; + background-color: #203175; + color: white; + border-style: none; + outline: none; +} + /* 导航 */ .header { padding: 10px 0; @@ -264,7 +290,8 @@ img { .news-hot-text { padding: 10px; background-color: rgba(0, 0, 0, .5); - height: 100px; + height: 30px; + width: 680px; position: absolute; bottom: 0; left: 0; @@ -284,16 +311,6 @@ img { color: white; } -.news-hot-more { - text-align: right; - padding-top: 10px; -} - -.news-hot-more i { - margin-left: 5px; - color: #fff; -} - .news-title { padding-top: 0; box-sizing: border-box; diff --git a/resources/views/article/search.blade.php b/resources/views/article/search.blade.php new file mode 100644 index 0000000..85eee58 --- /dev/null +++ b/resources/views/article/search.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('title', '搜索结果') + + +@section('content') + + +
+ +
+ + +
+ @if ($articles->isNotEmpty()) + {{ $articles->appends(['title'=>request()->title])->links('layouts.pagination') }} + @endif +
+
+
+ + +@endsection diff --git a/resources/views/category/show.blade.php b/resources/views/category/show.blade.php index 2689747..10a832c 100644 --- a/resources/views/category/show.blade.php +++ b/resources/views/category/show.blade.php @@ -9,7 +9,7 @@
{{ $parent->title }} -

Exchange and cooperation

+

{{ $parent->description }}