<?php

use App\Role;
use App\User;
use Illuminate\Database\Seeder;

/**
 * Class TestUsersSeeder
 */
class TestUsersSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // If there is a user with specified email, just update the record, else create it
        $user = User::updateOrCreate(
            [
                'email' => 'entity-manager@jkozlovsky.cz'
            ],
            [
                'name' => config('admin.name', 'Administrator'),
                'password' => bcrypt(config('admin.password', "123456"))
            ]
        );

        $user->attachRole(Role::DEVICE_MANAGER_ID);

        // If there is a user with specified email, just update the record, else create it
        $user = User::updateOrCreate(
            [
                'email' => 'auditor@jkozlovsky.cz'
            ],
            [
                'name' => config('admin.name', 'Administrator'),
                'password' => bcrypt(config('admin.password', "123456"))
            ]
        );

        $user->attachRole(Role::AUDITOR_ID);
    }
}
