<?php

use App\Model\Master\ProdukDarah;
use Illuminate\Database\Seeder;

class Create_produk_darah extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //
        DB::beginTransaction();

        $produk_darah = [
            ['AHF', 'AHF: Cryoprecipitated AHF'],
            ['FFP', 'FFP (Fresh Frozen Plasma)'],
            ['FP', 'FP: Fresh Plasma'],
            ['Lekosit Aferesis', 'Lekosit Aferesis'],
            ['Leucodepleted', 'Leucodepleted'],
            ['Leucoreduced', 'Leucoreduced'],
            ['LP', 'LP: Liquid Plasma'],
            ['LP Aferesis', 'LP AFERESIS'],
            ['PRC', 'PRC: Packed Red Cell'],
            ['PRC Aferesis', 'PRC AFERESIS'],
            ['PRC Pediatrik', '	PRC Pediatrik'],
            ['PRP', 'PRP (Platelet Rich Plasma)'],
            ['TC', 'TC: Trombocyte Concentrate'],
            ['TC Apheresis', 'TC Apheresis'],
            ['WB', 'WB: Whole Blood'],
            ['WE', 'WE: Washed Erythrocyte'],
        ];

        $arr_insert = [];
        foreach ($produk_darah as $key => $value) {
            $arr_insert[] = [
                'nama' => $value[0],
                'deskripsi' => $value[1],
                'is_show' => 'Y',
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ];
        }
        $sqlInsert = ProdukDarah::insert($arr_insert);

        if ($sqlInsert) {
            DB::commit();
        } else {
            DB::rollback();
        }
    }
}