app/Http/Controllers/KitItemController.php
/*
     * Get All kit item by central office ID Or, kit type id or Both
     *
     */
Get All kit item by central office ID Or, kit type id or Both
Get All kit item by central office ID Or kit type id or Both
public function kitItemsByQuery( Request $request ){
        try{
            $central_office_id = $request->input('central_office_id');
            $item_type_id =  $request->input('item_type_id');
            $status = $request->input('status') ? $request->input('status') : 0;
            if( !$central_office_id && !$item_type_id )
                throw new Exception("Central office ID Or Kit type id required required");
            $whereClouse = [];
            if( $central_office_id && $item_type_id ){
                $whereClouse = ['central_office_id'=>$central_office_id, 'item_type_id'=> $item_type_id];
            }elseif( $central_office_id ){
                $whereClouse = ['central_office_id' => $central_office_id];
            }elseif( $item_type_id ){
                $whereClouse = ['item_type_id'=> $item_type_id];
            }
            $whereClouse['status']= $status;
            $kitItems = KitItem::getKitItemByCentralOffice($whereClouse);
            $object = [];
            if( count($kitItems) > 0 ){
                foreach( $kitItems as $kitItem){
                    $kitItemObj = new \stdClass();
                    $kitItemObj->id  = $kitItem->id;
                    $kitItemObj->kit_name = $kitItem->ItemType->type_name;
                    $kitItemObj->central_office_name = $kitItem->centralOffice->central_name;
                    $kitItemObj->status = $kitItem->status;
                    $kitItemObj->image = $kitItem->image;
                    array_push($object, $kitItemObj);
                }
            }
            return ['success'=>true, 'data'=>$object,'message'=>'Central office data retrieve'];
        }catch (Exception $e){
            return ['success'=>false, 'message'=>$e->getMessage()];
        }
    }
public function kitItemsByQuery ( Request $ request ) { try { $ central_office_id = $ request -> input ( 'central_office_id' ) ; $ item_type_id = $ request -> input ( 'item_type_id' ) ; $ status = $ request -> input ( 'status' ) ? $ request -> input ( 'status' ) : 0 ; if ( ! $ central_office_id && ! $ item_type_id ) throw new Exception ( " Central office ID Or Kit type id required required " ) ; $ whereClouse = [ ] ; if ( $ central_office_id && $ item_type_id ) { $ whereClouse = [ 'central_office_id' => $ central_office_id , 'item_type_id' => $ item_type_id ] ; } elseif ( $ central_office_id ) { $ whereClouse = [ 'central_office_id' => $ central_office_id ] ; } elseif ( $ item_type_id ) { $ whereClouse = [ 'item_type_id' => $ item_type_id ] ; } $ whereClouse [ 'status' ] = $ status ; $ kitItems = KitItem :: getKitItemByCentralOffice ( $ whereClouse ) ; $ object = [ ] ; if ( count ( $ kitItems ) > 0 ) { foreach ( $ kitItems as $ kitItem ) { $ kitItemObj = new \ stdClass ( ) ; $ kitItemObj -> id = $ kitItem -> id ; $ kitItemObj -> kit_name = $ kitItem -> ItemType -> type_name ; $ kitItemObj -> central_office_name = $ kitItem -> centralOffice -> central_name ; $ kitItemObj -> status = $ kitItem -> status ; $ kitItemObj -> image = $ kitItem -> image ; array_push ( $ object , $ kitItemObj ) ; } } return [ 'success' => true , 'data' => $ object , 'message' => 'Central office data retrieve' ] ; } catch ( Exception $ e ) { return [ 'success' => false , 'message' => $ e -> getMessage ( ) ] ; } }
Get All kit item by central office ID Or, kit type id or Both
Get All kit item by central office ID Or kit type id or Both