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 unitLevelPendingRequest(Request $request){
        try{
            if(!$request->input('condemnation_id'))
                throw new Exception("Condemnation Id required");
            $unitUser = $request->user();
            if(!$unitUser || !$unitUser->hasRole('unit'))
                throw new Exception("Please try to login as unit user!");
            $pendingRequest = KitItemRequest::where([
                'unit_user_id'=>$unitUser->id,
                'condemnation_id'=>$request->input('condemnation_id'),
                'status'=>1
            ])->whereIn('stage', array(1,2,4,5))->get();
            if(count($pendingRequest) > 0 ){
                foreach($pendingRequest as $pRequest){
                    $pRequest->kit_items = \GuzzleHttp\json_decode($pRequest->kit_items);
                    $company = TermRelation::getCompanyInfoByUserId($pRequest->company_user_id);
                    if($company) {
                        $pRequest->company_name = $company->company_name;
                        $pRequest->company_device_id = $company->company_device_id;
                        $pRequest->company_user_name = $company->user_name;
                        $pRequest->user_designation = $company->designation;
                    }
                }
            }
            return ['success'=>true,'data'=>$pendingRequest];
        }catch (Exception $e){
            return ['success'=>false, 'message'=>$e->getMessage()];
        }
    }
public function unitLevelPendingRequest ( Request $ request ) { try { if ( ! $ request -> input ( 'condemnation_id' ) ) throw new Exception ( " Condemnation Id required " ) ; $ unitUser = $ request -> user ( ) ; if ( ! $ unitUser || ! $ unitUser -> hasRole ( 'unit' ) ) throw new Exception ( " Please try to login as unit user! " ) ; $ pendingRequest = KitItemRequest :: where ( [ 'unit_user_id' => $ unitUser -> id , 'condemnation_id' => $ request -> input ( 'condemnation_id' ) , 'status' => 1 ] ) -> whereIn ( 'stage' , array ( 1 , 2 , 4 , 5 ) ) -> get ( ) ; if ( count ( $ pendingRequest ) > 0 ) { foreach ( $ pendingRequest as $ pRequest ) { $ pRequest -> kit_items = \ GuzzleHttp \ json_decode ( $ pRequest -> kit_items ) ; $ company = TermRelation :: getCompanyInfoByUserId ( $ pRequest -> company_user_id ) ; if ( $ company ) { $ pRequest -> company_name = $ company -> company_name ; $ pRequest -> company_device_id = $ company -> company_device_id ; $ pRequest -> company_user_name = $ company -> user_name ; $ pRequest -> user_designation = $ company -> designation ; } } } 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