<?php

namespace Database\Seeders;

use App\Models\User;
use Hash;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class DummyMemberSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $userEmails = [
            'admin@linksehat.dev' => ['administrator'],
            'manager+one@gmail.com' => ['corporate-manager'],
            'manager+two@gmail.com' => ['corporate-manager'],
            'hospitaladmin@gmail.com' => ['hospital-admin'],
            'accounting@linksehat.com' => ['accounting'],
        ];

        foreach ($userEmails as $email => $roles) {
            $user = User::updateOrCreate([
                'email' => $email
            ], [
                'email' => $email,
                'password' => Hash::make('password')
            ]);

            if (isset($roles) && count($roles)) {
                $user->syncRoles($roles);
            }
        }
    }
}
