<?php

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

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