<?php

namespace App\Console\Commands;


use Carbon\Carbon;
use Illuminate\Console\Command;
use DB;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Portal\Ecuti\Model\LeaveBalance;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redirect;
use Portal\Ecuti\Model\VwMainAppVerify;
use Portal\Ecuti\Model\VwMainAppApproval;
use Portal\Ecuti\Model\MainApp;



class UpdateVerify extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'schedule:update-verify';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Update Uid for verify_by,approval_by in main_app';
    // Maklumat Cuti Staf untuk Tahun Semasa      
    // Termasuk Baki Cuti Rehat dan Cuti Sakit 
 

    /**
     * Create a new command instance.
     *
     * @return void
     */
   /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        //update balance CSAK
        $verify = VwMainAppVerify::get();
               
            foreach ($verify as $key => $value) 
            {
                
                $update = MainApp::where('id', '=', $value->id)->first();
                $update->supported_by = $value->vuid;
                $update->update();
                             
            }

                              
         $approve = VwMainAppApproval::get();
               
            foreach ($approve as $key => $value) 
            {
                
                $update = MainApp::where('id', '=', $value->id)->first();
                $update->approved_by = $value->auid;
                $update->update();
                             
            }

    }
}

