Exemple #1
0
 public static function addTags($tags)
 {
     $res = Tag::findAll(['name' => $tags]);
     foreach ($res as $tag) {
         $tag->updateCounters(['frequency' => 1]);
     }
     foreach ($tags as $name) {
         if (!Tag::findOne(['name' => $name])) {
             $tag = new Tag();
             $tag->name = $name;
             $tag->frequency = 1;
             $tag->save();
         }
     }
 }