静态资源
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user