重新导入数据
This commit is contained in:
@@ -18,7 +18,7 @@ class IndexController extends AdminController
|
||||
public function grid()
|
||||
{
|
||||
$grid = new Grid(new Article);
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
$grid->model()->orderBy('created_at', 'desc');
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('title', '文章标题');
|
||||
|
||||
@@ -21,6 +21,7 @@ class TestController extends Controller
|
||||
//检查分类
|
||||
public function checkCategory()
|
||||
{
|
||||
dd(1);
|
||||
|
||||
// $lists = Category::where('created_at','2020-06-03 15:57:55')->get();
|
||||
// $i=1;
|
||||
@@ -54,6 +55,9 @@ class TestController extends Controller
|
||||
|
||||
public function setCateArticle()
|
||||
{
|
||||
dd(1);
|
||||
|
||||
|
||||
$article = [];
|
||||
$lists = Category::where('content', '<>', '')->where('type', 'article')->get();
|
||||
if ($lists->isEmpty()) {
|
||||
@@ -87,27 +91,28 @@ 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();
|
||||
if (!$cate || !$old) {
|
||||
dump($old);
|
||||
dump($cate);
|
||||
dd('出问题了');
|
||||
}
|
||||
$list->category_id = $cate->id;
|
||||
$list->save();
|
||||
}
|
||||
dd();
|
||||
dd(1);
|
||||
// $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());
|
||||
dump(count($articleids));
|
||||
dump(count($oldids));
|
||||
dump($diffids);
|
||||
die();
|
||||
dd();
|
||||
$map = [
|
||||
'id' => ['in', $diffids],
|
||||
];
|
||||
@@ -116,7 +121,7 @@ class TestController extends Controller
|
||||
$data = [
|
||||
'oldid' => $article->id,
|
||||
'title' => $article->title,
|
||||
'category_id' => $category->id ?? '0',
|
||||
// 'category_id' => $category->id ?? '0',
|
||||
'writer' => $article->writer,
|
||||
'cover' => $article->litpic,
|
||||
'source' => $article->source,
|
||||
@@ -133,6 +138,8 @@ class TestController extends Controller
|
||||
//导入文章
|
||||
public function set_article()
|
||||
{
|
||||
dd(1);
|
||||
|
||||
$articles = Article::get();
|
||||
if ($articles->count() > 4) {
|
||||
dd('已经导入过数据');
|
||||
@@ -159,7 +166,7 @@ class TestController extends Controller
|
||||
];
|
||||
|
||||
$res = Article::create($data);
|
||||
if (!$res) {
|
||||
if (! $res) {
|
||||
$error[] = $article->id;
|
||||
} else {
|
||||
$success[] = $article->id;
|
||||
@@ -174,6 +181,8 @@ class TestController extends Controller
|
||||
//导入分类
|
||||
public function set_category()
|
||||
{
|
||||
dd(1);
|
||||
|
||||
$categorys = Category::get();
|
||||
if ($categorys->count() > 1) {
|
||||
dd('已经导入过数据');
|
||||
|
||||
Reference in New Issue
Block a user