2021_04_06_092844_create_demand_authorities.php 753 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use App\Authority;
  3. use Illuminate\Database\Migrations\Migration;
  4. class CreateDemandAuthorities extends Migration
  5. {
  6. private $authorities = [
  7. '需求管理-问题-删除'
  8. ];
  9. /**
  10. * Run the migrations.
  11. *
  12. * @return void
  13. */
  14. public function up()
  15. {
  16. foreach ($this->authorities as $name){
  17. Authority::query()->firstOrCreate(
  18. ['name' => $name],
  19. ['name' => $name,'alias_name' => $name]
  20. );
  21. }
  22. }
  23. /**
  24. * Reverse the migrations.
  25. *
  26. * @return void
  27. */
  28. public function down()
  29. {
  30. foreach ($this->authorities as $name){
  31. Authority::query()->where('name' ,$name)->delete();
  32. }
  33. }
  34. }