<?php

namespace Database\Seeders;

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

class ContactUsTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $this->seedOldData();
    }

    /**
     * Seed old postshop data
     */
    public function seedOldData(): void
    {
        $datas = json_decode(File::get('database/data/contact_us.json'));

        $table = 'contact_us';
        foreach ($datas as $data) {
            DB::table($table)->insert([
                'title' => $data->title,
                'phone' => $data->phone,
                'content' => $data->content,
                'type' => $data->type,
                'created_at' => $data->created_at,
                'updated_at' => $data->updated_at,
            ]);
        }
    }
}
