<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument;
use App\Modules\Clients\Client;
use App\Modules\Clients\Customer;
use App\Modules\Clients\SiteUser;
use App\Modules\Bookings\Task;
use App\Modules\Bookings\Project;
use App\Modules\Bookings\SaleLead;
use App\Modules\Bookings\Support;
use App\Modules\Bookings\Comment;
use App\Modules\Admin\EmailSettings;
use Illuminate\Support\Facades\DB;
use App\Console\Commands\AbstractCommand;


class mapHaniel extends AbstractCommand
{
    /**
     * A friendly name of the command that will be used when loggin messages.
     *
     * @var string
     */
    protected $command_title = 'maps haniel';

    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'map:haniel';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'adds haniel id';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
	{
        if (($handle = fopen("./hanielseraphmatchv2.csv", "r")) !== FALSE) {
            while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
				if ($data[2]) {
                    DB::table('clients')
                        ->where('id', $data[2])
                        ->update(['Haniel_ID' =>$data[0]]);
				}
                
                echo "\n";
            }
            fclose($handle);
        }
    }

}
