<?php

namespace Database\Seeders;

use App\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Seeder;

class UserRoleSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $users = User::query()->get();

        foreach($users as $user){
            $user->assignRole('guest');
        }

        $admin = User::updateOrCreate([
            'name' => 'admin',
            'email' => 'admin@unesa.ac.id'
        ],[
            'email_verified_at' => Carbon::now(),
            'password' => bcrypt('unesa123')
        ]);

        $admin->assignRole('admin');
    }
}
