<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use TCG\Voyager\Models\Role;

class RolesTableSeederCustom extends Seeder
{

    /**
     * Auto generated seed file
     *
     * @return void
     */
    public function run()
    {
        $role = $this->getRole(6);
        if (!$role->exists) {
            $role->fill(["name" => "manager", "display_name" => "Manager"])->save();
        }

        $role = $this->getRole(7);
        if (!$role->exists) {
            $role->fill(["name" => "suborganizer", "display_name" => "Sub-Organizer (sub-organizer)"])->save();
        }
    }

    /**
     * [dataRow description].
     *
     * @param [type] $type  [description]
     * @param [type] $field [description]
     *
     * @return [type] [description]
     */
    protected function getRole($id)
    {
        return Role::firstOrNew([
            'id'           => $id,
        ]);
    }
    
}