<?php

class ProductionAdminSeeder extends DatabaseSeeder {

	public function run()
	{
		DB::table('users')->truncate(); // Using truncate function so all info will be cleared when re-seeding.
		DB::table('roles')->truncate();
		DB::table('role_users')->truncate();
		DB::table('activations')->truncate();

		$admin = Sentinel::registerAndActivate(array(
			'email'       => 'admin@blpservice.it',
			'password'    => "Bp784951-",
			'first_name'  => 'BLP',
			'last_name'   => 'Service',
		));
                
		$admin1 = Sentinel::registerAndActivate(array(
			'email'       => 'admin@admin.com',
			'password'    => "admin",
			'first_name'  => 'Admin',
			'last_name'   => 'Admin',
		));
                
		$tecnico = Sentinel::registerAndActivate(array(
			'email'       => 'tecnico@tecnico.com',
			'password'    => "tecnico",
			'first_name'  => 'Tecnico',
			'last_name'   => 'Tecnico',
//                        'tecnico_id' => 4
		));

		$cliente = Sentinel::registerAndActivate(array(
			'email'       => 'cliente@cliente.com',
			'password'    => "cliente",
			'first_name'  => 'Cliente',
			'last_name'   => 'Cliente',
//                        'cliente_id'  => 13
		));                

		$adminRole = Sentinel::getRoleRepository()->createModel()->create([
			'name' => 'Admin',
			'slug' => 'admin',
			'permissions' => array('admin' => 1),
		]);

		$tecnicoRole = Sentinel::getRoleRepository()->createModel()->create([
			'name' => 'Tecnico',
			'slug' => 'tecnico',
			'permissions' => array('tecnico' => 1),
		]);

		$clienteRole = Sentinel::getRoleRepository()->createModel()->create([
			'name' => 'Cliente',
			'slug' => 'cliente',
			'permissions' => array('cliente' => 1),
		]);                     

		$admin->roles()->attach($adminRole);
                $admin1->roles()->attach($adminRole);
                $tecnico->roles()->attach($tecnicoRole);
                $cliente->roles()->attach($clienteRole);

		$this->command->info('Admin User created with username admin@blpservice.it and password Bp784951-');
                $this->command->info('Admin User created with username admin@admin.com and password admin');
                $this->command->info('Tecnico User created with username tecnico@tecnico.com and password tecnico');
                $this->command->info('Cliente User created with username cliente@cliente.com and password cliente');
                
	}

}