<?php

use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
use App\Models\Pouzivatel\Pouzivatel;
use App\Models\Pracovisko\Pracovisko;

/**
 * Class PouzivateliaDatabaseSeeder
 */
class PouzivateliaDatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        $pek = factory(Pracovisko::class)->create([
            'kod' => '0000',
            'nazov' => 'S-EKA, spol. s r.o.'
        ]);

        $admin = [
            'login' => '0000-lukac',
            'meno' => 'Radoslav Lukáč',
            'blokovany' => false,
        ];

        factory(Pouzivatel::class)->make($admin)
            ->assignRole(Role::create(['name' => 'admin']))
            ->givePermissionTo('vzdelavanie')
            ->pracovisko()
            ->associate($pek)
            ->save();
    }
}
