2020_06_04_162259_add_exit_authority.php 828 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 AddExitAuthority extends Migration
  7. {
  8. protected $authNames=[
  9. "订单管理",
  10. "订单管理-发运",
  11. "订单管理-批量备注",
  12. ];
  13. /**
  14. * Run the migrations.
  15. *
  16. * @return void
  17. */
  18. public function up()
  19. {
  20. foreach ($this->authNames as $name){
  21. if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
  22. }
  23. }
  24. /**
  25. * Reverse the migrations.
  26. *
  27. * @return void
  28. */
  29. public function down()
  30. {
  31. foreach ($this->authNames as $name){
  32. Authority::where('name',$name)->delete();
  33. }
  34. }
  35. }