阶段性更新

This commit is contained in:
2021-10-09 13:12:45 +08:00
parent ae95c5540b
commit d89bc90cef
248 changed files with 8676 additions and 5682 deletions

View File

@@ -9,27 +9,24 @@ class ArticleController extends Controller
{
/**
* 显示分类
* @param \App\Models\Article $article
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View [type] [description]
* Notes: description
* @Author: 玄尘
* @Date : 2021/10/8 14:54
* @param \App\Models\Article $article
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show(Article $article)
{
// $parent = $category = $article->category;
// if ($category->childrens->isEmpty()) {
// $parent = $category->parent;
// }
// $advert = Advert::where('category_id',73)->first();
$categories = $article->categories;
$parent = [];
foreach ($categories as $category) {
$top = getTopCate($category->id);
$parent[] = $top->id;
$parent = $category = $article->category;
if ($category->childrens->isEmpty() && $category->parent) {
$parent = $category->parent;
}
return view('article.show', compact('article', 'parent'));
// return view('article.show', compact('article', 'parent', 'category','advert'));
$article->increment('clicks');
return view('article.show', compact('article', 'parent', 'category'));
}

View File

@@ -10,7 +10,7 @@ class CategoryController extends Controller
/**
* 显示分类
* @param Category $category [description]
* @param Category $category [description]
* @return [type] [description]
*/
public function index(Category $category)
@@ -18,14 +18,25 @@ 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)->where('status', 1)->latest()->paginate();
$parent = $category;
if ($parent->childrens->isEmpty()) {
$template = 'show';
if ($category->template) {
$template = $category->template;
}
$articles = $category->relations(Category::TYPE_ARTICLE)
->where('status', 1)
->latest('sort')
->latest('created_at')
->paginate(8);
$parent = $category;
if ($category->childrens->isEmpty() && $category->parent) {
$parent = $category->parent;
}
return view('category.show', compact('articles', 'category', 'parent'));
return view('category.' . $template, compact('articles', 'category', 'parent'));
}
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Advert;
use App\Models\Category;
use App\Models\Link;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
@@ -21,19 +22,21 @@ class Controller extends BaseController
$categorys = Category::where('status', 1)
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
->where('top_show', 1)
->latest('order')
->oldest('order')
->select('id', 'title')
->get();
//地步友情链接
//友情链接
if (url()->current() == route('index.index')) {
$adverts = Advert::where('category_id', 72)->get();
} else {
$adverts = Advert::where('category_id', 73)->get();
}
$links = Link::get();
View::share('all_categorys', $categorys);
View::share('adverts', $adverts);
View::share('links', $links);
}
}

View File

@@ -17,12 +17,11 @@ class IndexController extends Controller
*/
public function index()
{
//研究中心
$links = Link::get();
$lt_adverts = Advert::where('category_id', 175)->latest('sort')->get();
$top_adverts = Advert::where('category_id', 33)->latest('sort')->first();
$cent_adverts = Advert::where('category_id', 33)->latest('sort')->first();
return view('index.index', compact('links', 'lt_adverts'));
return view('index.index', compact('top_adverts', 'top_adverts'));
}
//通用获取文章