2020_03_25_164120_create_process_methods_table.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. use Illuminate\Support\Facades\DB;
  3. use Illuminate\Support\Facades\Schema;
  4. use Illuminate\Database\Schema\Blueprint;
  5. use Illuminate\Database\Migrations\Migration;
  6. class CreateProcessMethodsTable extends Migration
  7. {
  8. protected $processMethods=['贴标','撕标','全检','组套','拆套','喷码','其他'];
  9. /**
  10. * Run the migrations.
  11. *
  12. * 二次加工类型
  13. *
  14. * @return void
  15. */
  16. public function up()
  17. {
  18. Schema::create('process_methods', function (Blueprint $table) {
  19. $table->bigIncrements('id');
  20. $table->string('name');
  21. $table->timestamps();
  22. });
  23. foreach ($this->processMethods as $processMethod){
  24. DB::insert(DB::raw("INSERT INTO process_methods(name,created_at,updated_at) VALUES(?,?,?)"),[
  25. $processMethod,date("Y-m-d"),date("Y-m-d")
  26. ]);
  27. }
  28. }
  29. /**
  30. * Reverse the migrations.
  31. *
  32. * @return void
  33. */
  34. public function down()
  35. {
  36. Schema::dropIfExists('process_methods');
  37. }
  38. }