diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 34d560a..9eece59 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -11,33 +11,43 @@ class CategoryController extends Controller /** * 显示分类 + * * @param Category $category [description] * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View [type] [description] */ public function index(Category $category) { if ($category->type == Category::TYPE_SHOW && $category->article_id) { - return redirect("articles/" . $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; + } else { + if ($category->type == Category::TYPE_VIDEO) { + $template = 'videos'; + } + + if ($category->type == Category::TYPE_ADVERT) { + $template = 'images'; + } } + $articles = $category->relations($category->type) - ->where('status', 1) - ->latest('sort') - ->latest('created_at') - ->paginate(); + ->where('status', 1) + ->latest('sort') + ->latest('created_at') + ->paginate(); $parent = $category; if ($category->childrens->isEmpty() && $category->parent) { $parent = $category->parent; } - return view('category.' . $template, compact('articles', 'category', 'parent')); + return view('category.'.$template, compact('articles', 'category', 'parent')); } } diff --git a/resources/views/category/images.blade.php b/resources/views/category/images.blade.php new file mode 100644 index 0000000..7571341 --- /dev/null +++ b/resources/views/category/images.blade.php @@ -0,0 +1,54 @@ +@extends('layouts.app') + +@section('title', $parent->title) + + +@section('css') + +@endsection + +@section('content') + + @include('category.navigation') + + +
{{ $article->title }}
+
+ 抱歉,暂无内容
+