<?php

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

class AddAuthorritiesToProcurement extends Migration
{
    private $names = [
        '采购管理',
        '采购管理-采购','采购管理-财务','采购管理-相关设置',
        '采购管理-采购-查询','采购管理-采购-新建','采购管理-采购-编辑',
        '采购管理-财务-对账单','采购管理-财务-采购账单','采购管理-财务-月账单报表',
    ];
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        foreach ($this->names as $name) {
            if(!Authority::query()->where('name',$name)->exists())
                Authority::query()->create(['name'=>$name,'alias_name'=>$name]);
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Authority::query()->whereIn('name',$this->names)->delete();
    }
}
