src/Http/Controllers/UssdController.php
public function continueUssdMenu($user,$message,$menu){
        //verify response
        $menu_items = self::getMenuItems($user->menu_id);

        $i = 1;
        $choice = "";
        $next_menu_id = 0;
        foreach ($menu_items as $key => $value) {
            if(self::validationVariations(trim($message),$i,$value->description)){
                $choice = $value->id;
                $next_menu_id = $value->next_menu_id;

                break;
            }
            $i++;
        }
        if(empty($choice)){
            //get error, we could not understand your response
            $response = "We could not understand your response". PHP_EOL;


            $i = 1;
            $response = $menu->title.PHP_EOL;
            foreach ($menu_items as $key => $value) {
                $response = $response . $i . ": " . $value->description . PHP_EOL;
                $i++;
            }

            return $response;
            //save the response
        }else{
            //there is a selected choice
            $menu = ussd_menu::find($next_menu_id);
            //next menu switch
            $response = self::nextMenuSwitch($user,$menu);
            return $response;
        }

    }
public function continueUssdMenu($user,$message,$menu){
        //verify response
        $menu_items = self::getMenuItems($user->menu_id);

        $i = 1;
        $choice = "";
        $next_menu_id = 0;
        foreach ($menu_items as $key => $value) {
            if(self::validationVariations(trim($message),$i,$value->description)){
                $choice = $value->id;
                $next_menu_id = $value->next_menu_id;

                break;
            }
            $i++;
        }
        if(empty($choice)){
            //get error, we could not understand your response
            $response = "We could not understand your response". PHP_EOL;


            $i = 1;
            $response = $menu->title.PHP_EOL;
            foreach ($menu_items as $key => $value) {
                $response = $response . $i . ": " . $value->description . PHP_EOL;
                $i++;
            }

            return $response;
            //save the response
        }else{
            //there is a selected choice
            $menu = ussd_menu::find($next_menu_id);
            //next menu switch
            $response = self::nextMenuSwitch($user,$menu);
            return $response;
        }

    }
public function continueUssdMenu ( $ user , $ message , $ menu ) { //verify response $ menu_items = self :: getMenuItems ( $ user -> menu_id ) ; $ i = 1 ; $ choice = "" ; $ next_menu_id = 0 ; foreach ( $ menu_items as $ key => $ value ) { if ( self :: validationVariations ( trim ( $ message ) , $ i , $ value -> description ) ) { $ choice = $ value -> id ; $ next_menu_id = $ value -> next_menu_id ; break ; } $ i ++ ; } if ( empty ( $ choice ) ) { //get error, we could not understand your response $ response = "We could not understand your response" . PHP_EOL ; $ i = 1 ; $ response = $ menu -> title . PHP_EOL ; foreach ( $ menu_items as $ key => $ value ) { $ response = $ response . $ i . ": " . $ value -> description . PHP_EOL ; $ i ++ ; } return $ response ; //save the response } else { //there is a selected choice $ menu = ussd_menu :: find ( $ next_menu_id ) ; //next menu switch $ response = self :: nextMenuSwitch ( $ user , $ menu ) ; return $ response ; } }
continue USSD Menu
continue USSD Menu