静态资源

This commit is contained in:
2020-09-16 08:35:46 +08:00
parent 24315e4798
commit ac3b53b163
40 changed files with 8270 additions and 660 deletions

View File

@@ -10,18 +10,20 @@ class ArticleController extends Controller
/**
* 显示分类
* @param Category $category [description]
* @param Category $category [description]
* @return [type] [description]
*/
public function show(Article $article)
{
$parent = $category = $article->category;
if ($category->childrens->isEmpty()) {
$parent = $category->parent;
}
$advert = Advert::where('category_id',73)->first();
$category = $article->category;
$parent = getTopCate($category->id);
return view('article.show', compact('article', 'parent', 'category','advert'));
$next = Article::where('id', '>', $article->id)
->where('category_id', $article->category_id)
->where('status', 1)
->first();
return view('article.show', compact('article', 'next', 'parent'));
}

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,15 +18,15 @@ 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)->paginate();
$articles = $category->relations(Category::TYPE_ARTICLE)->paginate(8);
$parent = $category;
if ($category->childrens->isEmpty()) {
$parent = $category->parent;
}
$advert = Advert::where('category_id',73)->first();
$advert = Advert::where('category_id', 73)->first();
return view('category.show', compact('articles', 'category', 'parent','advert'));
return view('category.show', compact('articles', 'category', 'parent', 'advert'));
}
}

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;
@@ -19,19 +20,15 @@ class Controller extends BaseController
{
//顶部分类
$categorys = Category::where('status', 1)
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
->where('top_show', 1)
->orderBy('order', 'desc')
->select('id', 'title')
->get();
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
->where('top_show', 1)
->orderBy('order', 'desc')
->select('id', 'title')
->get();
$links = Link::get();
//地步友情链接
if (url()->current() == route('index.index')) {
$adverts = Advert::where('category_id', 26)->get();
View::share('adverts', $adverts);
}
View::share('all_categorys', $categorys);
View::share('links', $links);
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Advert;
use App\Models\Article;
use App\Models\Link;
@@ -15,26 +16,29 @@ class IndexController extends Controller
*/
public function index()
{
$fydt = $this->getArticle([6], 9); //分院动态
$kydt = $this->getArticle([9], 9); //科研动态
$ldbz = $this->getArticle([3], 4); //领导班子
$kycg = $this->getArticle([10], 8); //科研成果
$rctd = $this->getArticle([4], 9); //人才团队介绍
$fydt = $this->getArticle([6], 9); //分院动态
$kydt = $this->getArticle([9], 9); //科研动态
$ldbz = $this->getArticle([3], 4); //领导班子
$kycg = $this->getArticle([10], 8); //科研成果
$rctd = $this->getArticle([4], 9); //人才团队介绍
$info = Article::where('category_id', 2)->first(); //院所介绍
$links = Link::get();
return view('index.index', compact('links', 'fydt', 'kydt', 'ldbz', 'kycg', 'rctd', 'info'));
$advert = Advert::where('category_id', 26)->latest('sort')->first();
$center_advert = Advert::where('category_id', 28)->latest('sort')->first();
return view('index.index', compact('advert', 'center_advert', 'fydt', 'kydt', 'ldbz', 'kycg', 'rctd', 'info'));
}
//通用获取文章
public function getArticle($category_ids, $take = 3)
{
return Article::whereIn('category_id', $category_ids)
->select('id', 'description', 'title', 'created_at', 'cover', 'content')
->latest('sort')
->latest()
->take($take)
->get();
->select('id', 'description', 'title', 'created_at', 'cover', 'content')
->latest('sort')
->latest()
->take($take)
->get();
}
}

View File

@@ -10,6 +10,7 @@ use App\Traits\Tree;
class TestController extends Controller
{
use Tree;
public function index()
@@ -40,9 +41,12 @@ class TestController extends Controller
dump(count($cateids));
dump(count($oldids));
dump($diffids);
dd();
foreach ($diffids as $diffid) {
$info = DedeArctype::where('id', $diffid)->where('ishidden', 0)->select('id', 'reid as parent_id', 'typename as title', 'content')->first();
$info = DedeArctype::where('id', $diffid)
->where('ishidden', 0)
->select('id', 'reid as parent_id', 'typename as title', 'content')
->first();
$data = $this->getData($info);
Category::create($data);
}
@@ -83,14 +87,20 @@ class TestController extends Controller
public function checkArticle()
{
// $lists = Article::where('category_id', 0)->get();
// foreach ($lists as $list) {
// $old = DedeArchive::find($list->oldid);
// $cate = Category::where('oldid', $old->typeid)->first();
// $list->category_id = $cate->id;
// $list->save();
// }
// dd();
$lists = Article::where('category_id', 0)->get();
foreach ($lists as $list) {
$old = DedeArchive::find($list->oldid);
$cate = Category::where('oldid', $old->typeid)->first();
if (!$cate || !$old) {
dump($old);
dump($cate);
dd('出问题了');
}
$list->category_id = $cate->id;
$list->save();
}
dd();
$articleids = Article::where('oldid', '>', 0)->pluck('oldid');
$oldids = DedeArchive::pluck('id');
$diffids = array_diff($oldids->toArray(), $articleids->toArray());
@@ -98,7 +108,7 @@ class TestController extends Controller
dump(count($oldids));
dump($diffids);
die();
$map = [
$map = [
'id' => ['in', $diffids],
];
$list = DedeArchive::whereIn('id', $diffids)->get();
@@ -128,7 +138,7 @@ class TestController extends Controller
dd('已经导入过数据');
}
$categorys = Category::get();
$error = $success = [];
$error = $success = [];
DedeArchive::whereNotNull('litpic')->chunk(200, function ($articles) use ($categorys) {
foreach ($articles as $article) {
@@ -168,7 +178,9 @@ class TestController extends Controller
if ($categorys->count() > 1) {
dd('已经导入过数据');
}
$lists = DedeArctype::where('ishidden', 0)->select('id', 'reid as parent_id', 'typename as title', 'content')->get();
$lists = DedeArctype::where('ishidden', 0)
->select('id', 'reid as parent_id', 'typename as title', 'content')
->get();
$list = Tree::list2tree($lists->toArray(), 'id', 'parent_id', 'children', 0);
foreach ($list as $key => $value) {
@@ -191,6 +203,7 @@ class TestController extends Controller
'content' => $category['content'],
'status' => 1,
];
return $data;
}