public function getYesOrNoId($answer)
 {
     $greekStringConversion = new GreekStringConversionHelper();
     $answer = $greekStringConversion->grstrtoupper($answer);
     foreach ($this->binaryYesNo as $binary) {
         $binary->description = $greekStringConversion->grstrtoupper($binary->description);
         if (strcasecmp($answer, $binary->description) == 0) {
             return $binary->id;
         }
     }
     // no yes or no found in answer
     return null;
 }
Example #2
0
 private function getWorkTitleIdFromDBAndInsertNewWorkTitleIfNeeded($workTitleFromForm)
 {
     // initialize the GreekStringConversionHelper service
     $greekStringConversion = new GreekStringConversionHelper();
     $workTitleId = null;
     $allWorkTitlesAvailable = \DB::table('work_title_list_lookup')->get();
     $workTitleFromForm = $greekStringConversion->grstrtoupper($workTitleFromForm);
     // if there are some work titles in DB
     if ($allWorkTitlesAvailable != null) {
         // check for each one if the names are the same after greek string conversion to uppercase
         foreach ($allWorkTitlesAvailable as $work_title) {
             $work_title->work_title = $greekStringConversion->grstrtoupper($work_title->work_title);
             // if strings are the same set the $workTitleId to the DB's id
             if (strcasecmp($work_title->work_title, $workTitleFromForm) == 0) {
                 $workTitleId = $work_title->id;
                 break;
             }
         }
     }
     // if work title was not found in DB
     if ($workTitleId == null) {
         $workTitleId = \DB::table('work_title_list_lookup')->insertGetId(array('work_title' => $workTitleFromForm));
     }
     return $workTitleId;
 }