<?php

namespace App\Http\Controllers\Administrator;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use Auth;
use DB;
use App\FundsTransactionModel;
use App\FundsRegisterModel;


class MultipleUpdateStatusController extends Controller
{
    

    public function withdraw_proccess_pay(Request $request)
    {
        $ids = $request->ids;
        FundsTransactionModel::whereIn('id',$ids)
        ->update([
			'status'    => 1,
            'done_date' => date('Y-m-d H:i:s A'),
            'app_rej_date'=> date('Y-m-d H:i:s A'),
		]);
        return response()->json(['status'=>true]);   
    }
	
	public function register_approved_rjected(Request $request)
    {
        $ids = $request->ids;
        $status = $request->status;
        //$update_status = 2 => Disative
        //$update_status = 1 => Active

		($status == 2)? $update_status = 2: $update_status = 1;
		
        if($status ==2){
            FundsRegisterModel::where('status','<>',2)->whereIn('id',explode(",",$ids))->update(['status' => $update_status,'reject_approve_date' => date('Y-m-d H:i:s A')]);
        }else{
            FundsRegisterModel::where('status','<>',1)->whereIn('id',explode(",",$ids))->update(['status' => $update_status,'reject_approve_date' => date('Y-m-d H:i:s A')]);
        }

        
        return response()->json(['status'=>true]);   
    }  
}