<?php

declare(strict_types=1);

namespace Database\Seeders;

use App\Models\Breed;
use App\Models\Category;
use App\Models\User;
use Illuminate\Database\Seeder;

class BreedsTableSeeder extends Seeder
{
    public function run(): void
    {
        $adminId = User::role('admin')->first()?->id;
        $cattleCategory = Category::where('slug', 'cattle')->first();
        $sheepCategory = Category::where('slug', 'sheep')->first();
        $goatCategory = Category::where('slug', 'goat')->first();

        $breeds = [
            ['name' => 'هلشتاین', 'en_name' => 'Holstein', 'category_id' => $cattleCategory?->id, 'desc' => 'نژاد شیری معروف'],
            ['name' => 'جرزی', 'en_name' => 'Jersey', 'category_id' => $cattleCategory?->id, 'desc' => 'نژاد شیری با چربی بالا'],
            ['name' => 'سیمنتال', 'en_name' => 'Simmental', 'category_id' => $cattleCategory?->id, 'desc' => 'نژاد دو منظوره گوشت و شیر'],
            ['name' => 'افشاری', 'en_name' => 'Afshari', 'category_id' => $sheepCategory?->id, 'desc' => 'نژاد گوشتی ایرانی'],
            ['name' => 'ماکویی', 'en_name' => 'Makui', 'category_id' => $sheepCategory?->id, 'desc' => 'نژاد پشمی ایرانی'],
            ['name' => 'سانن', 'en_name' => 'Saanen', 'category_id' => $goatCategory?->id, 'desc' => 'نژاد شیری بز'],
            ['name' => 'آلباین', 'en_name' => 'Alpine', 'category_id' => $goatCategory?->id, 'desc' => 'نژاد شیری بز'],
        ];

        foreach ($breeds as $breed) {
            Breed::firstOrCreate(
                ['name' => $breed['name']],
                [
                    'en_name' => $breed['en_name'],
                    'category_id' => $breed['category_id'],
                    'desc' => $breed['desc'],
                    'status' => 'active',
                    'created_by' => $adminId,
                    'updated_by' => $adminId,
                ]
            );
        }
    }
}
