<?php

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

class AddPayableUjrahBranchesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('payable_ujrah_branches', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('details_caw');
            $table->string('kodcaw');
            $table->boolean('gadaian_ujrah_payable')->default(false);
            $table->timestamps();
        });

        $this->getBranches()->each(function($branch) {
            PayableUjrahBranch::create([
                'details_caw' => $branch['details_caw'],
                'kodcaw' => $branch['kodcaw'],
            ]);
        });

    }

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

    public function getBranches()
    {
        $branches = [
            [
                "details_caw" => "Kota Bharu 2",
                "kodcaw" => "KB2"
            ],
            [
                "details_caw" => "Wakaf Che Yeh",
                "kodcaw" => "WCY"
            ],
            [
                "details_caw" => "1 Stop",
                "kodcaw" => "1STOP"
            ],
            [
                "details_caw" => "Jelawat",
                "kodcaw" => "020301"
            ],
            [
                "details_caw" => "Wakaf Bharu",
                "kodcaw" => "WB"
            ],
            [
                "details_caw" => "Kok Lanas",
                "kodcaw" => "ALS"
            ],
            [
                "details_caw" => "Pasir Puteh",
                "kodcaw" => "020306"
            ],
            [
                "details_caw" => "Machang",
                "kodcaw" => "ARM"
            ],
            [
                "details_caw" => "Pasir Mas",
                "kodcaw" => "APM"
            ],
            [
                "details_caw" => "Gua Musang",
                "kodcaw" => "010311"
            ],
            [
                "details_caw" => "Guchil",
                "kodcaw" => "GC"
            ],
            [
                "details_caw" => "Jeli",
                "kodcaw" => "JLI"
            ],
            [
                "details_caw" => "Rantau Panjang",
                "kodcaw" => "ARP"
            ],
            [
                "details_caw" => "Kuantan",
                "kodcaw" => "010621"
            ],
            [
                "details_caw" => "Pasir Gudang",
                "kodcaw" => "010136"
            ],
            [
                "details_caw" => "Skudai",
                "kodcaw" => "011235"
            ],
            [
                "details_caw" => "Putatan",
                "kodcaw" => "011227"
            ],
            [
                "details_caw" => "Bentong",
                "kodcaw" => "010620"
            ],
            [
                "details_caw" => "Raub",
                "kodcaw" => "010617"
            ],
            [
                "details_caw" => "Kangar",
                "kodcaw" => "010915"
            ],
            [
                "details_caw" => "Sandakan",
                "kodcaw" => "011228"
            ],
            [
                "details_caw" => "Sungai Petani",
                "kodcaw" => "010219"
            ],
            [
                "details_caw" => "Tawau",
                "kodcaw" => "011229"
            ],
            [
                "details_caw" => "Api-Api",
                "kodcaw" => "011230"
            ],
            [
                "details_caw" => "Kajang",
                "kodcaw" => "011013"
            ],
            [
                "details_caw" => "Raja Laut",
                "kodcaw" => "011412"
            ],
            [
                "details_caw" => "Beaufort",
                "kodcaw" => "011231"
            ],
            [
                "details_caw" => "Kota Belud",
                "kodcaw" => "011232"
            ],
            [
                "details_caw" => "Tuaran",
                "kodcaw" => "011234"
            ],
            [
                "details_caw" => "Keningau",
                "kodcaw" => "011233"
            ],
            [
                "details_caw" => "Tanah Merah",
                "kodcaw" => "020303"
            ],
            [
                "details_caw" => "Temerloh",
                "kodcaw" => "010618"
            ],
            [
                "details_caw" => "Semporna",
                "kodcaw" => "011237"
            ],
            [
                "details_caw" => "Kota Bharu 1",
                "kodcaw" => "KB1"
            ]
        ];

        return collect($branches);
    }
}
