app/Http/Controllers/ItemRequestController.php
/*
     * Central will review each pending request that comes from district level
     */
Central will review each pending request that comes from district level
Central will review each pending request that comes from district level
public function reviewPendingRequestById(Request $request){
        try{
            if(!$request->input('request_id'))
                throw new Exception("Must be need request Id");
            $centralUser = $request->user();
            if(!$centralUser || !$centralUser->hasRole('central'))
                throw new Exception("Please logged in as a central level");
            $pendingRequest = KitItemRequest::where([
                'id'=>$request->input('request_id'),
                'status'=> 4 
            ])->whereIn('stage', array(1,2))->first();
            if(!$pendingRequest)
                throw new Exception("Sorry pending request not found");
            $centralTerms = TermRelation::where(['user_id'=>$centralUser->id,'role'=>1,'term_type'=>0])->first();
            $hasItems = KitItem::getFreeItemNumberByCentralOffice($centralTerms->central_office_id);
            return ['success'=>true, 'total_items'=>$hasItems, 'pendingRequest'=>$pendingRequest];
        }catch (Exception $e){
            return ['success'=>false, 'message'=>$e->getMessage()];
        }
    }
public function reviewPendingRequestById ( Request $ request ) { try { if ( ! $ request -> input ( 'request_id' ) ) throw new Exception ( " Must be need request Id " ) ; $ centralUser = $ request -> user ( ) ; if ( ! $ centralUser || ! $ centralUser -> hasRole ( 'central' ) ) throw new Exception ( " Please logged in as a central level " ) ; $ pendingRequest = KitItemRequest :: where ( [ 'id' => $ request -> input ( 'request_id' ) , 'status' => 4 ] ) -> whereIn ( 'stage' , array ( 1 , 2 ) ) -> first ( ) ; if ( ! $ pendingRequest ) throw new Exception ( " Sorry pending request not found " ) ; $ centralTerms = TermRelation :: where ( [ 'user_id' => $ centralUser -> id , 'role' => 1 , 'term_type' => 0 ] ) -> first ( ) ; $ hasItems = KitItem :: getFreeItemNumberByCentralOffice ( $ centralTerms -> central_office_id ) ; return [ 'success' => true , 'total_items' => $ hasItems , 'pendingRequest' => $ pendingRequest ] ; } catch ( Exception $ e ) { return [ 'success' => false , 'message' => $ e -> getMessage ( ) ] ; } }
Central will review each pending request that comes from district level
Central will review each pending request that comes from district level
//formation