app/Http/Controllers/ItemRequestController.php
/*
     * Update unit level json data
     * approve=true
     */
Update unit level json data
approve=true
Update unit level json data approve = true
private function updateCentralKitData($request_id, $central_user_id){
        $pendingRequest = KitItemRequest::where([
            'central_user_id'=>$central_user_id,
            'status'=> 4 
        ])->whereIn('stage', array(1,2,3))->get();
        foreach( $pendingRequest as $index=>$pRequest){
            $kitItems = \GuzzleHttp\json_decode($pRequest->kit_items);
            $saveKitItems = \GuzzleHttp\json_decode($pRequest->kit_items);
            if(count($kitItems) > 0 ){
                foreach ($kitItems as $key=>$subKitItem){ 
                    $kitItems[$key]->quarter_master = TermRelation::getQuarterMasterInfoByUserId($subKitItem->quarter_master_user_id);
                    foreach($subKitItem->kit_items as $q=>$unitLevel) { 
                        $kitItems[$key]->kit_items[$q]->unit = TermRelation::getUnitInfoByUserId($unitLevel->unit_user_id);
                        if( $unitLevel->request_id == $request_id ) {
                            $kitItems[$key]->kit_items[$q]->approve = true;
                            $saveKitItems[$key]->kit_items[$q]->approve = true;
                        }
                        if (is_array($unitLevel->kit_items)) {
                            foreach ($unitLevel->kit_items as $k => $companyLevel) { 
                                $kitItems[$key]->kit_items[$q]->kit_items[$k]->company = TermRelation::getCompanyInfoByUserId($companyLevel->company_user_id);
                                $kitItems[$key]->kit_items[$q]->kit_items[$k]->items = KitItem::getKitItemsByIds(explode(',',$companyLevel->kit_items->kit_ids));
                            }
                        }
                    }
                }
            }
            $pRequest->kit_items = \GuzzleHttp\json_encode($saveKitItems);
            $pRequest->save();
            $pRequest->kit_items = $kitItems;
        }
        return $pendingRequest;
    }
private function updateCentralKitData ( $ request_id , $ central_user_id ) { $ pendingRequest = KitItemRequest :: where ( [ 'central_user_id' => $ central_user_id , 'status' => 4 ] ) -> whereIn ( 'stage' , array ( 1 , 2 , 3 ) ) -> get ( ) ; foreach ( $ pendingRequest as $ index => $ pRequest ) { $ kitItems = \ GuzzleHttp \ json_decode ( $ pRequest -> kit_items ) ; $ saveKitItems = \ GuzzleHttp \ json_decode ( $ pRequest -> kit_items ) ; if ( count ( $ kitItems ) > 0 ) { foreach ( $ kitItems as $ key => $ subKitItem ) { $ kitItems [ $ key ] -> quarter_master = TermRelation :: getQuarterMasterInfoByUserId ( $ subKitItem -> quarter_master_user_id ) ; foreach ( $ subKitItem -> kit_items as $ q => $ unitLevel ) { $ kitItems [ $ key ] -> kit_items [ $ q ] -> unit = TermRelation :: getUnitInfoByUserId ( $ unitLevel -> unit_user_id ) ; if ( $ unitLevel -> request_id == $ request_id ) { $ kitItems [ $ key ] -> kit_items [ $ q ] -> approve = true ; $ saveKitItems [ $ key ] -> kit_items [ $ q ] -> approve = true ; } if ( is_array ( $ unitLevel -> kit_items ) ) { foreach ( $ unitLevel -> kit_items as $ k => $ companyLevel ) { $ kitItems [ $ key ] -> kit_items [ $ q ] -> kit_items [ $ k ] -> company = TermRelation :: getCompanyInfoByUserId ( $ companyLevel -> company_user_id ) ; $ kitItems [ $ key ] -> kit_items [ $ q ] -> kit_items [ $ k ] -> items = KitItem :: getKitItemsByIds ( explode ( ',' , $ companyLevel -> kit_items -> kit_ids ) ) ; } } } } } $ pRequest -> kit_items = \ GuzzleHttp \ json_encode ( $ saveKitItems ) ; $ pRequest -> save ( ) ; $ pRequest -> kit_items = $ kitItems ; } return $ pendingRequest ; }
Update unit level json data
 approve=true
Update unit level json data approve = true
//formation // quarter mast //units // company