<?php

namespace Database\Seeders;

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

class UserSeeder extends Seeder
{
    public function run(): void
    {
        $admin = User::create([
            'name' => 'مدير النظام',
            'email' => 'admin@tagerplus.com',
            'phone' => '01000000000',
            'password' => Hash::make('password'),
            'is_admin' => true,
            'is_active' => true,
            'points_balance' => 0,
        ]);
        $admin->assignRole('admin');

        $storeManager = User::create([
            'name' => 'مدير المخازن',
            'email' => 'store@tagerplus.com',
            'phone' => '01066666666',
            'password' => Hash::make('password'),
            'is_admin' => true,
            'is_active' => true,
            'points_balance' => 0,
        ]);
        $storeManager->assignRole('store_manager');

        $salesAgent = User::create([
            'name' => 'موظف المبيعات',
            'email' => 'sales@tagerplus.com',
            'phone' => '01077777777',
            'password' => Hash::make('password'),
            'is_admin' => true,
            'is_active' => true,
            'points_balance' => 0,
        ]);
        $salesAgent->assignRole('sales_agent');

        $merchants = [
            ['name' => 'أحمد محمد', 'email' => 'ahmed@example.com', 'phone' => '01011111111'],
            ['name' => 'محمد علي', 'email' => 'mohamed@example.com', 'phone' => '01022222222'],
            ['name' => 'سارة أحمد', 'email' => 'sara@example.com', 'phone' => '01033333333'],
            ['name' => 'فاطمة حسن', 'email' => 'fatma@example.com', 'phone' => '01044444444'],
            ['name' => 'عمر خالد', 'email' => 'omar@example.com', 'phone' => '01055555555'],
        ];

        foreach ($merchants as $merchant) {
            User::create([
                'name' => $merchant['name'],
                'email' => $merchant['email'],
                'phone' => $merchant['phone'],
                'password' => Hash::make('password'),
                'is_admin' => false,
                'is_active' => true,
                'points_balance' => rand(0, 100),
            ]);
        }
    }
}
