| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- use App\Authority;
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- class AddPersonnelAuthority extends Migration
- {
- protected $deleteAuthNames=[
- '二次加工管理-打卡审核',
- '二次加工管理-登记工时-审核',
- ];
- protected $authNames=[
- '人事管理',
- '人事管理-门卫审核',
- '人事管理-任务审核',
- '人事管理-录入补卡',
- '人事管理-打卡',
- '工作组',
- '工作组-查询',
- '工作组-编辑',
- '工作组-录入',
- '工作组-删除',
- ];
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- foreach ($this->deleteAuthNames as $name){
- Authority::where('name',$name)->delete();
- }
- foreach ($this->authNames as $name){
- if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
- }
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- foreach ($this->authNames as $name){
- Authority::where('name',$name)->delete();
- }
- foreach ($this->deleteAuthNames as $name){
- if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
- }
- }
- }
|