<?php

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

class CreateOrderIssueTypesTable extends Migration
{
    protected $types = [
        '拦截',
        '快递异常',
        '信息更改',
        '联系不上',
        '其他',
        '错漏发',
        '仓库问题',
        '快递丢件',
        '破损',
        '撤销丢件',
        '二次加工',
        '全检问题',
        '系统问题',
        '延迟发货',
        '仓库丢件',
    ];

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_issue_types', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->String('name')->unique();
        });

        foreach ($this->types as $type){
            \App\OrderIssueType::create(['name'=>$type]);
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_issue_types');
    }
}
