2021_04_16_142212_add_authority_supplier.php 774 B

123456789101112131415161718192021222324252627282930313233343536
  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 AddAuthoritySupplier extends Migration
  7. {
  8. protected $authNames=[
  9. '供应商-可见全部',
  10. ];
  11. /**
  12. * Run the migrations.
  13. *
  14. * @return void
  15. */
  16. public function up()
  17. {
  18. foreach ($this->authNames as $name){
  19. if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
  20. }
  21. }
  22. /**
  23. * Reverse the migrations.
  24. *
  25. * @return void
  26. */
  27. public function down()
  28. {
  29. foreach ($this->authNames as $name){
  30. Authority::where('name',$name)->delete();
  31. }
  32. }
  33. }