<?php

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

class UsersTableAdminsSeeder extends Seeder
{
    protected $adminsData = [
        ['nickname' => 'Vladimir', 'email' => 'pol8best@gmail.com', 'password' => '0000'],
        ['nickname' => 'Bufon', 'email' => 'bufon@gmail.com', 'password' => '0000'],
        ['nickname' => 'Alex', 'email' => 'alex@gmail.com', 'password' => '0000'],
    ];

    public function run()
    {
        foreach ($this->adminsData as $data) {
            try {
                $admin = User::firstOrNew($data);
                $admin->password = bcrypt($data['password']);
                $admin->role_id = 1;
                $admin->save();
            } catch (\Exception $e) {
                echo "This one is already used";
            }
        }
    }
}
