<?php

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

class CreateForwarderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('forwarder', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name', 50);
            $table->string('email', 80)->nullable();
            $table->decimal('shipping_rate', 7, 2)->default(0);
            $table->decimal('markup_percentage', 7, 2)->default(0);
            $table->decimal('minimum_cbm', 5, 2)->default(0);
            $table->timestamps();
        });
        DB::table('forwarder')->insert(
            [
                'name' => 'CIEF Worldwide SDN BHD',
                'email' => 'infociefworldwide@gmail.com',
                'shipping_rate' => '300',
                'markup_percentage' => '0',
                'minimum_cbm' =>'0.3',
                'created_at' =>  \Carbon\Carbon::now(),
                'updated_at' => \Carbon\Carbon::now()
            ]
        );

        DB::table('address_book')->insert([
            'type' => 0,
            'reference_id' => 1,
            'street_one' => 'Malaysian Global Innovation & Creativity Centre(MaGIC)',
            'street_two' => ' CWS Block, 3730, Persiaran Apec',
            'city' => 'Cyberjaya',
            'state' => 'Selangor',
            'post_code' => '63000',
            'country' => 'Malaysia',
        ]);
    }

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