YzCategorySeeder.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/3/10
  6. * Time: 下午2:21
  7. */
  8. use Illuminate\Database\Seeder;
  9. class YzCategorySeeder extends Seeder
  10. {
  11. protected $oldTable = 'sz_yi_category';
  12. protected $newTable = 'yz_category';
  13. public function run()
  14. {
  15. return;
  16. $newList = \Illuminate\Support\Facades\DB::table($this->newTable)->get();
  17. if($newList->isNotEmpty()){
  18. echo "yz_category 已经有数据了跳过\n";
  19. return ;
  20. }
  21. $list = \Illuminate\Support\Facades\DB::table($this->oldTable)->get();
  22. if($list) {
  23. foreach ($list as $v) {
  24. \Illuminate\Support\Facades\DB::table($this->newTable)->insert([
  25. 'id'=> $v['id'],
  26. 'uniacid'=> $v['uniacid'],
  27. 'name'=> $v['name'],
  28. 'thumb'=> $v['thumb'],
  29. 'parent_id'=> $v['parentid'],
  30. 'description'=> $v['description'],
  31. 'display_order'=> $v['displayorder'],
  32. 'enabled'=> $v['enabled'],
  33. 'is_home'=> $v['ishome'],
  34. 'adv_img'=> $v['advimg'],
  35. 'adv_url'=> $v['advurl'],
  36. 'level'=> $v['level'],
  37. 'created_at'=> time(),
  38. 'updated_at'=> NULL,
  39. 'deleted_at'=> NULL
  40. ]);
  41. }
  42. }
  43. }
  44. }