<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;

class AkunsTableSeeder extends Seeder
{
    public function run()
    {
        $akun1 = 'Biaya yang Masih Harus Dibayar';
        $existing1 = DB::table('akuns')->where('name', $akun1)->first();
        if (!$existing1) {
            DB::table('akuns')->insert([
                'perent_id' => 48,
                'name' => $akun1,
                'total' => 0,
                'iscash' => 0,
                'isheader' => 0,
                'iscashout' => 0,
                'iscashin' => 0,
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),
            ]);
        }

        $akun2 = 'Hutang Pembelian Aset Tetap';
        $existing2 = DB::table('akuns')->where('name', $akun2)->first();
        if (!$existing2) {
            DB::table('akuns')->insert([
                'perent_id' => 48,
                'name' => $akun2,
                'total' => 0,
                'iscash' => 0,
                'isheader' => 0,
                'iscashout' => 0,
                'iscashin' => 0,
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),
            ]);
        }

        $akun3 = 'Cadangan Wajib';
        $existing2 = DB::table('akuns')->where('name', $akun3)->first();
        if (!$existing2) {
            DB::table('akuns')->insert([
                'perent_id' => 2,
                'name' => $akun3,
                'total' => 0,
                'iscash' => 0,
                'isheader' => 0,
                'iscashout' => 0,
                'iscashin' => 0,
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),
            ]);
        }

        $akun4 = 'Simpanan Wajib';
        $existing2 = DB::table('akuns')->where('name', $akun4)->first();
        if (!$existing2) {
            DB::table('akuns')->insert([
                'perent_id' => 2,
                'name' => $akun4,
                'total' => 0,
                'iscash' => 0,
                'isheader' => 0,
                'iscashout' => 0,
                'iscashin' => 0,
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),
            ]);
        }

        $akun5 = 'Prive';
        $existing2 = DB::table('akuns')->where('name', $akun5)->first();
        if (!$existing2) {
            DB::table('akuns')->insert([
                'perent_id' => 2,
                'name' => $akun5,
                'total' => 0,
                'iscash' => 0,
                'isheader' => 0,
                'iscashout' => 0,
                'iscashin' => 0,
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),
            ]);
        }
    }
}
