<?php

namespace Database\Seeders\Localization;

use App\Models\Localization\Locale;
use Illuminate\Database\Seeder;

class LocalesTableSeeder extends Seeder {
    public array $locales = [
        'ru' => ['title' => 'Русский'],
        'en' => ['title' => 'Английский'],
        'de' => ['title' => 'Немецкий'],
        'fr' => ['title' => 'Французский'],
        'it' => ['title' => 'Итальянский'],
        'es' => ['title' => 'Испанский'],
        'cn' => ['title' => 'Китайский'],
        'ar' => ['title' => 'Арабский', 'rtl' => true],
        'hi' => ['title' => 'Хинди']
    ];

    public function run() {
        collect($this->locales)->each(function($data, $name) {
            $model = Locale::firstOrCreate(['name' => $name]);
            $model->update(collect($data)->all());
        });
    }
}
