<?php

namespace Database\Seeders;

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

class IrotomesodeCategorySeeder extends Seeder
{
    /**
     * 色留袖・男着物 category を着物種類グループに追加する
     */
    public function run()
    {
        $categories = [
            ['name' => '色留袖', 'slug' => '色留袖', 'position' => 7],
            ['name' => '男着物', 'slug' => '男着物', 'position' => 8],
        ];

        foreach ($categories as $cat) {
            $exists = DB::table('categories')
                ->where('name', $cat['name'])
                ->where('parent_id', 109)
                ->exists();

            if (!$exists) {
                DB::table('categories')->insert([
                    'name' => $cat['name'],
                    'slug' => $cat['slug'],
                    'image' => '',
                    'parent_id' => 109,
                    'sub_title' => '',
                    'group' => null,
                    'description' => '',
                    'rank' => null,
                    'position' => $cat['position'],
                    'is_activated' => 1,
                    'is_deleted' => 0,
                    'created_at' => now(),
                    'updated_at' => now(),
                ]);
            }
        }
    }
}
