<?php

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

class AddAuthorityTableProcessRollback extends Migration
{

    protected $authNames=[
        '二次加工管理-回滚',
    ];
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        foreach ($this->authNames as $name){
            \App\Authority::create(['name'=>$name,'alias_name'=>$name,'permission'=>'允许']);
        }
        Schema::table('processes',function (Blueprint $table){
            $table->softDeletes();
        });
        Schema::table('waybills',function (Blueprint $table){
            $table->decimal('other_charge',7,3)->nullable()->comment('其他收费，原其他费用为其他支出');
            $table->text('other_charge_remark')->nullable()->comment('其他收费备注');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        foreach ($this->authNames as $name){
            \App\Authority::where(['name'=>$name,'alias_name'=>$name])->delete();
        }
        Schema::table('processes',function (Blueprint $table){
            $table->dropSoftDeletes();
        });
        Schema::table('waybills',function (Blueprint $table){
            $table->dropColumn('other_charge');
            $table->dropColumn('other_charge_remark');
        });
    }
}
