<?php

namespace Database\Seeders;

use App\Models\Language;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class LanguageSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $languages = [
            [
                'iso_code'        => 'en_US',
                'locale'          => 'en',
                'country_code'    => 'US',
                'title'           => 'English',
                'title_localized' => 'English',
            ],
            [
                'iso_code'        => 'de_DE',
                'locale'          => 'de',
                'country_code'    => 'DE',
                'title'           => 'German',
                'title_localized' => 'Deutsch',
            ],
            [
                'iso_code'        => 'fr_FR',
                'locale'          => 'fr',
                'country_code'    => 'FR',
                'title'           => 'French',
                'title_localized' => 'Français',
            ],
            [
                'iso_code'        => 'es_SP',
                'locale'          => 'es',
                'country_code'    => 'SP',
                'title'           => 'Spanish',
                'title_localized' => 'Español',
            ],
            [
                'iso_code'        => 'jp_JP',
                'locale'          => 'jp',
                'country_code'    => 'JP',
                'title'           => 'Japanese',
                'title_localized' => '日本',
            ],
            [
                'iso_code'        => 'zh_TW',
                'locale'          => 'zh',
                'country_code'    => 'TW',
                'title'           => 'Taiwanese',
                'title_localized' => '台湾',
            ],
        ];

        $startTime = Carbon::now();
        $offset = 0;

        foreach ($languages as $language) {
            $datetime = $startTime->copy()->addMinute($offset)->toDateTimeString();
            $offset++;
            $language['created_at'] = $datetime;
            $language['updated_at'] = $datetime;
            Language::create($language);
        }
    }
}
