<?php

use App\Authority;
use Illuminate\Database\Migrations\Migration;

class AddBasicSettingAuthority extends Migration
{
    protected $authNames=[
        "基础设置-用户", "基础设置-角色",
        "基础设置-权限", "基础设置-工作组",
        "基础设置-项目组", "基础设置-仓库",
        "基础设置-货主", "基础设置-品质标签",
        "基础设置-作业类型", "基础设置-商品信息",
        "基础设置-计量单位", "基础设置-省份",
        "基础设置-城市", "基础设置-地域",
        "基础设置-承运商", "基础设置-车型",
        "基础设置-特征", "基础设置-计费模型",
        "基础设置-纸箱", "基础设置-测量设备",
        "基础设置-教程", "基础设置-临时工",
        "基础设置-劳务所", "基础设置-邮件",
        "基础设置-日志", "基础设置-耗材类型",
        "基础设置-项目耗材", "基础设置-供应商",
        "基础设置-税率", "基础设置-系统配置",
        "基础设置-装卸队",
    ];
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        foreach ($this->authNames as $name){
            if(!Authority::query()->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::query()->where('name',$name)->delete();
        }
    }
}
