<?php

use App\Authority;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddProcessAuthority extends Migration
{

    protected $authNames=[
        '二次加工管理',
        '二次加工管理-查询',
        '二次加工管理-录入',
        '二次加工管理-编辑',
        '二次加工管理-删除',
        '二次加工管理-打卡审核',
        '二次加工管理-接单与驳回',
        '二次加工管理-登记工时',
        '二次加工管理-登记工时-审核',
        '二次加工管理-验收完成',
        '二次加工管理-教程管理',
        '二次加工管理-临时工资料管理',
    ];

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        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();
        }
    }
}
