<?php

namespace Database\Seeders;

use App\Libs\Consts\StatusConst;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

class UserTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
        DB::table('users')->truncate();

        $password = Hash::make('P@$$w0rd');

        $data = [
            [
                'id' => 1,
                'uuid' => Str::uuid()->toString(),
                'username' => 'jfradejas',
                'email' => 'owa.ojt.dev@gmail.com',
                'salt' => explode('.', $password)[0],
                'password' => $password,
                'role_id' => 1,
                'status' => StatusConst::ACTIVE,
                'verified' => StatusConst::VERIFIED,
                'display_name' => 'full',
                'social_site' => 'desxpert',
                'app_id' => config('desxpert.app_id'),
                'created_at' => Date('Y-m-d'),
                'created_by' => 1,
            ]
        ];

        DB::table('users')->insert($data);

        DB::table('user_profiles')->truncate();

        $data = [
            'user_id' => 1,
            'first_name' => 'joshua',
            'last_name' => 'fradejas',
            'middle_name' => 'dalisay',
            'gender' => 'male',
            'birthday' => date_create("1990-03-15"),
            'mobile_number' => '09324453444',
            'brgy' => 'san vicente',
            'city' => 'binan',
            'state' => 'laguna',
            'country' => 'philippines',
            'zip_code' => '4024',
            'current_address' => 'blk 22 lot 8',
        ];

        DB::table('user_profiles')->insert($data);


        DB::statement('SET FOREIGN_KEY_CHECKS=1;');
    }
}