<?php

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

class AddUnitJianTuo extends Migration
{
    protected $names=[
        '件',
        '托',
    ];
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        foreach ($this->names as $name){
            if(!Unit::where('name',$name)->first())(new Unit(['name'=>$name]))->save();
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        foreach ($this->names as $name){
            Unit::where('name',$name)->delete();
        }
    }
}
