2020_05_14_091440_add_personnel_authority.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 AddPersonnelAuthority extends Migration
  7. {
  8. protected $deleteAuthNames=[
  9. '二次加工管理-打卡审核',
  10. '二次加工管理-登记工时-审核',
  11. ];
  12. protected $authNames=[
  13. '人事管理',
  14. '人事管理-门卫审核',
  15. '人事管理-任务审核',
  16. '人事管理-录入补卡',
  17. '人事管理-打卡',
  18. '工作组',
  19. '工作组-查询',
  20. '工作组-编辑',
  21. '工作组-录入',
  22. '工作组-删除',
  23. ];
  24. /**
  25. * Run the migrations.
  26. *
  27. * @return void
  28. */
  29. public function up()
  30. {
  31. foreach ($this->deleteAuthNames as $name){
  32. Authority::where('name',$name)->delete();
  33. }
  34. foreach ($this->authNames as $name){
  35. if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
  36. }
  37. }
  38. /**
  39. * Reverse the migrations.
  40. *
  41. * @return void
  42. */
  43. public function down()
  44. {
  45. foreach ($this->authNames as $name){
  46. Authority::where('name',$name)->delete();
  47. }
  48. foreach ($this->deleteAuthNames as $name){
  49. if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
  50. }
  51. }
  52. }