models/Tag.php
public static function addTags($tags)
    {
        self::updateAllCounters(['frequency' => 1], ['name' => $tags]);

        foreach ($tags as $name) {
            if (!self::find()->where(['name' => $name])->exists()) {
                (new self([
                    'name' => $name,
                    'frequency' => 1
                ]))->save();
            }
        }
    }
public static function addTags($tags)
    {
        self::updateAllCounters(['frequency' => 1], ['name' => $tags]);

        foreach ($tags as $name) {
            if (!self::find()->where(['name' => $name])->exists()) {
                (new self([
                    'name' => $name,
                    'frequency' => 1
                ]))->save();
            }
        }
    }
public static function addTags ( $ tags ) { self :: updateAllCounters ( [ 'frequency' => 1 ] , [ 'name' => $ tags ] ) ; foreach ( $ tags as $ name ) { if ( ! self :: find ( ) -> where ( [ 'name' => $ name ] ) -> exists ( ) ) { ( new self ( [ 'name' => $ name , 'frequency' => 1 ] ) ) -> save ( ) ; } } }
Update frequency of tags and add new tags
@param $tags
Update frequency of tags and add new tags