app/Http/Controllers/ItemRequestController.php
/*
    * Get all pending request by condemnation id
    */
Get all pending request by condemnation id
Get all pending request by condemnation id
public function formationLevelPendingRequest(Request $request){
        try{
            $formationUser = $request->user();
            if(!$formationUser || !$formationUser->hasRole('formation'))
                throw new Exception("Please try to login as formation user!");
            $pendingRequest = KitItemRequest::where([
                'district_user_id'=>$formationUser->id,
                'status'=> 3 
            ])->whereIn('stage', array(1,2,4,5))->get();
            if(count($pendingRequest) == 0 ){
                throw new Exception("Formation have not any pending request");
            }
            foreach( $pendingRequest as $pRequest){
                $kitItems = \GuzzleHttp\json_decode($pRequest->kit_items);
                $pRequest->quarter_master_office = TermRelation::getQuarterMasterInfoByUserId($pRequest->quarter_master_user_id);
                if(count($kitItems) > 0 ){
                    foreach ($kitItems as $key=>$item ){
                        $kitItems[$key]->unit_office = TermRelation::getUnitInfoByUserId($item->unit_user_id);
                        if(count($item->kit_items) > 0 ) {
                            foreach($item->kit_items as $k=>$sItem) {
                                $item->kit_items[$k]->company = TermRelation::getCompanyInfoByUserId($sItem->company_user_id);
                            }
                        }
                    }
                }
                $pRequest->kit_items = $kitItems;
            }
            return ['success'=>true,'data'=>$pendingRequest];
        }catch (Exception $e){
            return ['success'=>false, 'message'=>$e->getMessage()];
        }
    }
public function formationLevelPendingRequest ( Request $ request ) { try { $ formationUser = $ request -> user ( ) ; if ( ! $ formationUser || ! $ formationUser -> hasRole ( 'formation' ) ) throw new Exception ( " Please try to login as formation user! " ) ; $ pendingRequest = KitItemRequest :: where ( [ 'district_user_id' => $ formationUser -> id , 'status' => 3 ] ) -> whereIn ( 'stage' , array ( 1 , 2 , 4 , 5 ) ) -> get ( ) ; if ( count ( $ pendingRequest ) == 0 ) { throw new Exception ( " Formation have not any pending request " ) ; } foreach ( $ pendingRequest as $ pRequest ) { $ kitItems = \ GuzzleHttp \ json_decode ( $ pRequest -> kit_items ) ; $ pRequest -> quarter_master_office = TermRelation :: getQuarterMasterInfoByUserId ( $ pRequest -> quarter_master_user_id ) ; if ( count ( $ kitItems ) > 0 ) { foreach ( $ kitItems as $ key => $ item ) { $ kitItems [ $ key ] -> unit_office = TermRelation :: getUnitInfoByUserId ( $ item -> unit_user_id ) ; if ( count ( $ item -> kit_items ) > 0 ) { foreach ( $ item -> kit_items as $ k => $ sItem ) { $ item -> kit_items [ $ k ] -> company = TermRelation :: getCompanyInfoByUserId ( $ sItem -> company_user_id ) ; } } } } $ pRequest -> kit_items = $ kitItems ; } return [ 'success' => true , 'data' => $ pendingRequest ] ; } catch ( Exception $ e ) { return [ 'success' => false , 'message' => $ e -> getMessage ( ) ] ; } }
Get all pending request by condemnation id
Get all pending request by condemnation id
//formation