<?php

namespace App\Http\Controllers\Administrator;

use App\FundsRegisterModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\ItemModel;
use DB;
use Illuminate\Support\Facades\Artisan;
class ZeroValueController extends Controller
{
    public function zero(){
        $tables = [
                    'log_activities',
                    'nso007_relationship_status',
                    'nso007_deposit',
                    'nso007_approve_instalment_step',
                    'nso007_approve_instalment',
                    'nso007_journal_accounting',
                    'nso007_blocked_item',
                    'nso007_sale_detail_stock',
                    'nso007_sale_stock',
                    'nso007_border',
                    'nso007_cancel_deposit',
                    'nso007_journal',
                    'nso007_liability',
                    'nso007_liability_history',
                    'nso007_loan',
                    'nso007_agency_commission',
                    'nso007_request_commission',
                    'nso007_agency_commission_list',
                    'nso007_loan_paid',
                    'nso007_admin_commission',
                    'nso007_admin_commission_report',
                    'nso007_loan_process',
                    'nso007_funds_transaction',
                    'nso007_item_stock_updated',
                    'nso007_approve_payment',
                    'nso007_loan_paid_cancel',
                    'nso007_agency_commission_report',
                    'nso007_admin_commission_report',
                    'nso007_approve_pos_edit',
                    'nso007_approve_pos_edit_item',
                    'nso007_sale_promotion_for_approval',
                    'nso007_sale_payment_policy_for_approval',
                    'nso007_sale_promotion',
                    'nso007_sale_policy_payment',
                    'nso007_loan_installment_change_rate_for_approve',
                    'nso007_loan_installment_with_bank_for_approve',
                    // 'nso007_item_stock',
                    // 'nso007_item_group',
                    // 'nso007_item_zone',
                    // 'nso007_project_stock',
                    // 'nso007_inventery_stock',
                    'nso007_deposit_schedule',
                    'nso007_loan_file_document',
                    'nso007_sale_bank_loan_procedures',
                    'nso007_sale_promotion_detail'
                ];
        foreach($tables as $table){
            DB::table($table)->truncate();
        }
        ItemModel::whereNotNull('id')->update([
            'item_stockstatus'  => 1,
            'block_status'      => 1,
            'item_salestatus'   => 0,
            'available'         => 1,
            'inv_id'            => null
        ]);
        FundsRegisterModel::whereNotNull('id')->update([
            'balance'          => 0,
            'received​_balance' => 0
        ]);
        $exitCode = Artisan::call('cache:clear');
        return redirect()->route('dashboard.super-admin')->with('success','Data Cleared');
    }
}
