This commit is contained in:
2021-12-01 13:34:38 +08:00
parent 52f73b3bc3
commit dffa07e4eb
22 changed files with 701 additions and 109 deletions

View File

@@ -10,23 +10,30 @@ 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);
} else {
$template = 'show';
$directory = 'category';
$template = 'show';
if ($category->template) {
$template = $category->template;
}
if ($category->type == Category::TYPE_PERSON) {
$directory = 'resume';
}
$articles = $category->relations(Category::TYPE_ARTICLE)
->where('status', 1)
->latest('sort')
->latest('created_at')
->paginate(8);
->where('status', 1)
->latest('sort')
->latest('created_at')
->paginate(8);
$parent = $category;
if ($category->childrens->isEmpty() && $category->parent) {
@@ -35,7 +42,7 @@ class CategoryController extends Controller
$advert = Advert::where('category_id', 73)->first();
return view('category.' . $template, compact('articles', 'category', 'parent', 'advert'));
return view($directory.'.'.$template, compact('articles', 'category', 'parent', 'advert'));
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers;
use App\Models\Advert;
use App\Models\Article;
use App\Models\Resume;
use Illuminate\Http\Request;
class ResumeController extends Controller
{
/**
* Notes: 显示详情
*
* @Author: 玄尘
* @Date: 2021/12/1 10:46
* @param \App\Models\Resume $resume
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show(Resume $resume)
{
$category = $resume->category;
$parent = $category;
if ($category->childrens->isEmpty() && $category->parent) {
$parent = $category->parent;
}
return view('resume.show', compact('resume', 'category','parent'));
}
}