<?php

namespace Database\Factories;

use App\Models\Teacher;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

class TeacherFactory extends Factory
{
    protected $model = Teacher::class;

    public function definition(): array
    {
        // 创建对应的用户记录
        $user = User::factory()->create([
            'role' => 'teacher',
        ]);

        $teacherId = 'teacher_' . $this->faker->unique()->numberBetween(1000, 9999);

        return [
            'teacher_id' => $teacherId,
            'user_id' => $user->user_id,
            'name' => $user->full_name,
            'subject' => $this->faker->randomElement(['数学', '语文', '英语', '物理', '化学', '生物']),
        ];
    }
}
