调整野蛮

This commit is contained in:
2021-04-07 13:18:18 +08:00
parent 96793afeec
commit ae95c5540b
14 changed files with 2170 additions and 808 deletions

View File

@@ -15,14 +15,21 @@ class ArticleController extends Controller
*/
public function show(Article $article)
{
// $parent = $category = $article->category;
// $parent = $category = $article->category;
// if ($category->childrens->isEmpty()) {
// $parent = $category->parent;
// }
// $advert = Advert::where('category_id',73)->first();
$categories = $article->categories;
$parent = [];
return view('article.show', compact('article'));
// return view('article.show', compact('article', 'parent', 'category','advert'));
foreach ($categories as $category) {
$top = getTopCate($category->id);
$parent[] = $top->id;
}
return view('article.show', compact('article', 'parent'));
// return view('article.show', compact('article', 'parent', 'category','advert'));
}

View File

@@ -20,10 +20,9 @@ class IndexController extends Controller
//研究中心
$links = Link::get();
$adverts = Advert::where('category_id', 72)->latest('sort')->get();
$lt_adverts = Advert::where('category_id', 175)->latest('sort')->get();
return view('index.index', compact('links', 'adverts', 'lt_adverts'));
return view('index.index', compact('links', 'lt_adverts'));
}
//通用获取文章

View File

@@ -22,7 +22,8 @@ class TestController extends Controller
public function set_article_category()
{
$articles = Article::whereHas('category')
$articles = Article::query()
->whereHas('category')
->chunk(200, function ($articles) {
foreach ($articles as $article) {
ArticleCategory::create([