public function getMultioptionFieldValue(string $fieldSlug, $key)
    {
        if(is_null($key)) {
            return null;
        }

        $field = $this->field($fieldSlug);
        if(!$field) {
            throw new \Exception("No field with slug ".$fieldSlug);
        }
        $options = explode(",", $field->multioptionValues);

        foreach ($options as $option){
            $optionArr = explode(":", $option);
            if($optionArr[0] == $key) {
                $value  = $optionArr[1];

                // remove comma
                if(substr($value, -1) == ',') {
                    $value = substr($value, 0, -1);
                }
                return $value;
            }
        }
    }
public function getMultioptionFieldValue(string $fieldSlug, $key)
    {
        if(is_null($key)) {
            return null;
        }

        $field = $this->field($fieldSlug);
        if(!$field) {
            throw new \Exception("No field with slug ".$fieldSlug);
        }
        $options = explode(",", $field->multioptionValues);

        foreach ($options as $option){
            $optionArr = explode(":", $option);
            if($optionArr[0] == $key) {
                $value  = $optionArr[1];

                // remove comma
                if(substr($value, -1) == ',') {
                    $value = substr($value, 0, -1);
                }
                return $value;
            }
        }
    }
public function getMultioptionFieldValue ( string $ fieldSlug , $ key ) { if ( is_null ( $ key ) ) { return null ; } $ field = $ this -> field ( $ fieldSlug ) ; if ( ! $ field ) { throw new \ Exception ( "No field with slug " . $ fieldSlug ) ; } $ options = explode ( "," , $ field -> multioptionValues ) ; foreach ( $ options as $ option ) { $ optionArr = explode ( ":" , $ option ) ; if ( $ optionArr [ 0 ] == $ key ) { $ value = $ optionArr [ 1 ] ; // remove comma if ( substr ( $ value , - 1 ) == ',' ) { $ value = substr ( $ value , 0 , - 1 ) ; } return $ value ; } } }
Get Value of a multioptions field by using it's key.

@param  string $fieldSlug
@param  string $key
@return mixed
@throws \Exception
Get Value of a multioptions field by using it s key .