<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Language;
use Illuminate\Support\Facades\File;

class LanguageSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $languages = [
            [
                'name' => 'Bangla', 
                'code' => 'bn', 
                'is_default' => false, 
                'is_rtl' => false
            ],
            [
                'name' => 'Arabic', 
                'code' => 'ar', 
                'is_default' => false, 
                'is_rtl' => true 
            ],
        ];

        foreach ($languages as $lang) {
            Language::updateOrCreate(
                ['code' => $lang['code']], 
                $lang
            );

            $path = lang_path("{$lang['code']}.json");
            if (!File::exists($path)) {
                File::put($path, '{}');
            }
        }
    }
}