2021_01_29_161734_add_units_data.php 606 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class AddUnitsData extends Migration
  6. {
  7. protected $units = [
  8. "件","箱",'单',"日","月","m²","m³","件","托"
  9. ];
  10. /**
  11. * Run the migrations.
  12. *
  13. * @return void
  14. */
  15. public function up()
  16. {
  17. foreach ($this->units as $unit){
  18. \App\Unit::query()->firstOrCreate(["name"=>$unit]);
  19. }
  20. }
  21. /**
  22. * Reverse the migrations.
  23. *
  24. * @return void
  25. */
  26. public function down()
  27. {
  28. }
  29. }