<?php

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

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

}
