2020_05_25_093853_change_waybills_table.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. use App\Authority;
  3. use Illuminate\Database\Migrations\Migration;
  4. use Illuminate\Database\Schema\Blueprint;
  5. use Illuminate\Support\Facades\Schema;
  6. class ChangeWaybillsTable extends Migration
  7. {
  8. protected $authNames=[
  9. "运输管理-发运"
  10. ];
  11. /**
  12. * Run the migrations.
  13. *
  14. * @return void
  15. */
  16. public function up()
  17. {
  18. Schema::table('waybills',function (Blueprint $table){
  19. $table->string('mileage')->nullable()->comment('里程');
  20. $table->bigInteger('amount')->nullable()->comment('件数');
  21. $table->string('inquire_tel')->nullable()->comment('查件电话');
  22. });
  23. foreach ($this->authNames as $name){
  24. if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
  25. }
  26. }
  27. /**
  28. * Reverse the migrations.
  29. *
  30. * @return void
  31. */
  32. public function down()
  33. {
  34. Schema::table('waybills',function (Blueprint $table){
  35. $table->dropColumn('mileage');
  36. $table->dropColumn('amount');
  37. $table->dropColumn('inquire_tel');
  38. });
  39. foreach ($this->authNames as $name){
  40. Authority::where('name',$name)->delete();
  41. }
  42. }
  43. }