<?php

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

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