<?php

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

class AddStoreTransferAuthority 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();
        }
    }
}
