2020_03_25_182324_add_process_authority.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. use App\Authority;
  3. use Illuminate\Support\Facades\Schema;
  4. use Illuminate\Database\Schema\Blueprint;
  5. use Illuminate\Database\Migrations\Migration;
  6. class AddProcessAuthority extends Migration
  7. {
  8. protected $authNames=[
  9. '二次加工管理',
  10. '二次加工管理-查询',
  11. '二次加工管理-录入',
  12. '二次加工管理-编辑',
  13. '二次加工管理-删除',
  14. '二次加工管理-打卡审核',
  15. '二次加工管理-接单与驳回',
  16. '二次加工管理-登记工时',
  17. '二次加工管理-登记工时-审核',
  18. '二次加工管理-验收完成',
  19. '二次加工管理-教程管理',
  20. '二次加工管理-临时工资料管理',
  21. ];
  22. /**
  23. * Run the migrations.
  24. *
  25. * @return void
  26. */
  27. public function up()
  28. {
  29. foreach ($this->authNames as $name){
  30. if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
  31. }
  32. }
  33. /**
  34. * Reverse the migrations.
  35. *
  36. * @return void
  37. */
  38. public function down()
  39. {
  40. foreach ($this->authNames as $name){
  41. Authority::where('name',$name)->delete();
  42. }
  43. }
  44. }