I am following blog guide for yii1 and I am trying to recreate everything with yii2.
I am stuck with addTags method of Tag model. I do not know how to convert this code to yii2. Can some1 help me please ?
public function addTags($tags)
{
$criteria = new CDbCriteria;
$criteria->addInCondition('name', $tags);
$this->updateCounters(array('frequency' => 1), $criteria);
foreach($tags as $name){
if(!$this->exists('name=:name', array(':name' => $name))){
$tag = new Tag;
$tag->name = $name;
$tag->frequency = 1;
$tag->save();
}
}
}
I am confused with this addInCondition, there is no such thing in yii2 as well as CDbCriteria. How to make this work in yii2 ?