<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class UpdateAboutUsCompanyInfoPage extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $now = now();
        $content = <<<'HTML'
<h2>会社情報</h2>
<table class="company-info-table">
    <tbody>
        <tr>
            <th>所在地</th>
            <td>〒832-0044 福岡県柳川市袋町16-2</td>
        </tr>
        <tr>
            <th>電話番号</th>
            <td>0944-72-4272</td>
        </tr>
    </tbody>
</table>
<div class="company-info-map">
    <iframe
        src="https://www.google.com/maps?q=%E3%80%92832-0044%20%E7%A6%8F%E5%B2%A1%E7%9C%8C%E6%9F%B3%E5%B7%9D%E5%B8%82%E8%A2%8B%E7%94%BA16-2&output=embed"
        loading="lazy"
        referrerpolicy="no-referrer-when-downgrade"
        allowfullscreen>
    </iframe>
</div>
HTML;

        DB::table('pages')->updateOrInsert(
            ['slug' => 'about-us'],
            [
                'title' => '会社情報',
                'description' => '会社情報',
                'content' => $content,
                'group' => 0,
                'user_id' => 1,
                'is_activated' => 1,
                'is_deleted' => 0,
                'created_at' => $now,
                'updated_at' => $now,
            ]
        );
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        DB::table('pages')
            ->where('slug', 'about-us')
            ->update([
                'description' => 'Description of 会社情報',
                'content' => 'Content of 会社情報',
                'updated_at' => now(),
            ]);
    }
}
