<?php

namespace Database\Seeders;

use App\Models\User;
use App\Models\School;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class UserSeeder extends Seeder
{
    public function run(): void
    {
        // Create sample schools first
        $school1 = School::create([
            'name' => 'Bungoma DEB Primary',
            'code' => 'KNA001',
            'type' => 'primary',
            'city' => 'Bungoma',
            'county' => 'Bungoma',
            'status' => 'active',
            'student_count' => 840,
            'teacher_count' => 42,
        ]);

        $school2 = School::create([
            'name' => 'Nairobi Elite Academy',
            'code' => 'NBI002',
            'type' => 'secondary',
            'city' => 'Nairobi',
            'county' => 'Nairobi',
            'status' => 'active',
            'student_count' => 1250,
            'teacher_count' => 68,
        ]);

        // Super Admin (no school)
        User::create([
            'name' => 'John Kamau',
            'email' => 'super@institutionaxis.com',
            'password' => Hash::make('password'),
            'role' => 'super_admin',
        ]);

        // School Admin linked to school
        User::create([
            'name' => 'Mr. Otieno',
            'email' => 'admin@school.com',
            'password' => Hash::make('password'),
            'role' => 'school_admin',
            'school_id' => $school1->id,
        ]);

        // Teacher linked to school
        User::create([
            'name' => 'Mrs. Moraa',
            'email' => 'teacher@institutionaxis.com',
            'password' => Hash::make('password'),
            'role' => 'teacher',
            'school_id' => $school1->id,
        ]);

        // Parent & Student (for future)
        User::create([
            'name' => 'Mrs. Wanjiku',
            'email' => 'parent@institutionaxis.com',
            'password' => Hash::make('password'),
            'role' => 'parent',
            'school_id' => $school1->id,
        ]);

        User::create([
            'name' => 'Kevin M.',
            'email' => 'student@institutionaxis.com',
            'password' => Hash::make('password'),
            'role' => 'student',
            'school_id' => $school1->id,
        ]);
    }
}