2020_03_11_111102_update_addresaddress_add_area.php 960 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class UpdateAddresaddressAddArea extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. if (Schema::hasTable('yz_address')) {
  15. $city = \app\common\models\Address::where( ['areaname' => '长春市', 'parentid' => 220000, 'level' => 2])->first();
  16. if ($city) {
  17. $aaa = \app\common\models\Address::where(['areaname' => '经开区', 'parentid'=> $city->id, 'level' => 3])->first();
  18. if(is_null($aaa)) {
  19. \app\common\models\Address::insert(['areaname' => '经开区', 'parentid'=> $city->id, 'level' => 3]);
  20. }
  21. }
  22. }
  23. }
  24. /**
  25. * Reverse the migrations.
  26. *
  27. * @return void
  28. */
  29. public function down()
  30. {
  31. //
  32. }
  33. }