<?php

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

class AddDataAuthoritiesIssue extends Migration
{
    protected $authNames = [
        "订单管理-订单问题件生成",
        "订单管理-问题件-查询",
//        "订单管理-问题件-工作量",
//        "订单管理-问题件-绩效统计",
        "订单管理-问题件-置顶",
        "订单管理-问题件-删除",
        "订单管理-问题件-编辑",
    ];

    protected $forbidAuthName =[
        '客户不可见'
    ];
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //
        foreach ($this->authNames as $authName){
           \App\Authority::create(['name'=>$authName,'alias_name'=>$authName,'permission'=>'允许']);
        }
        foreach ($this->forbidAuthName as $bidAuthName){
            \App\Authority::create(['name'=>$bidAuthName,'alias_name'=>$bidAuthName,'permission'=>'禁止']);
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        foreach ($this->authNames as $authName){
            \App\Authority::where(['name'=>$authName,'alias_name'=>$authName])->delete();
        }
        foreach ($this->forbidAuthName as $bidAuthName){
            \App\Authority::where(['name'=>$bidAuthName,'alias_name'=>$bidAuthName])->delete();
        }
    }
}
