/**
  * Retrieve all the tags from the BD and count the number of occurrences of each tag
  * @return Array with the tags and the number of times they were mentioned
  */
 function sumAllTags()
 {
     $data = FacebookTags::all();
     //Retrieve all data relative to tags
     $sumTags = array();
     $tags = json_decode($data);
     foreach ($tags as $key => $value) {
         $tags = $value->Tags;
         foreach ($tags as $id => $tagValue) {
             if (isset($sumTags[$id])) {
                 $sumTags[$id] += $tagValue;
             } else {
                 $sumTags[$id] = $tagValue;
             }
         }
     }
     return $sumTags;
 }
Example #2
0
 /**
  * This function will verify if a tag is already in the database
  * @param String $tagName the identification of the tag
  * @param String $city the city related to the tags
  * @return bool Return true if the tag exist, otherwise return false
  */
 private function tagsExist($tagName, $city)
 {
     $tagModel = new FacebookTags();
     $verifyTag = $tagModel->where("City", $city);
     if (isset($verifyTag->get()[0]->Tags[$tagName])) {
         return true;
     } else {
         return false;
     }
 }