2020_07_23_113747_add_authorities_personnel.php 821 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 AddAuthoritiesPersonnel extends Migration
  7. {
  8. protected $authNames=[
  9. '人事管理-临时工报表',
  10. '人事管理-打卡相关',
  11. ];
  12. /**
  13. * Run the migrations.
  14. *
  15. * @return void
  16. */
  17. public function up()
  18. {
  19. foreach ($this->authNames as $name){
  20. if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
  21. }
  22. }
  23. /**
  24. * Reverse the migrations.
  25. *
  26. * @return void
  27. */
  28. public function down()
  29. {
  30. foreach ($this->authNames as $name){
  31. Authority::where('name',$name)->delete();
  32. }
  33. }
  34. }