models/Tag.php
public static function suggest($keyword, $limit = 20)
    {
        /** @var self[] $tags */
        $tags = self::find()
            ->where(['like', 'name', $keyword])
            ->orderBy('frequency DESC, name')
            ->limit($limit)
            ->all();

        $names = array();

        foreach ($tags as $tag) {
            $names[] = ['word' => Html::encode($tag->name)];
        }

        return $names;
    }
public static function suggest($keyword, $limit = 20)
    {
        /** @var self[] $tags */
        $tags = self::find()
            ->where(['like', 'name', $keyword])
            ->orderBy('frequency DESC, name')
            ->limit($limit)
            ->all();

        $names = array();

        foreach ($tags as $tag) {
            $names[] = ['word' => Html::encode($tag->name)];
        }

        return $names;
    }
public static function suggest ( $ keyword , $ limit = 20 ) { /** @var self[] $tags */ $ tags = self :: find ( ) -> where ( [ 'like' , 'name' , $ keyword ] ) -> orderBy ( 'frequency DESC, name' ) -> limit ( $ limit ) -> all ( ) ; $ names = array ( ) ; foreach ( $ tags as $ tag ) { $ names [ ] = [ 'word' => Html :: encode ( $ tag -> name ) ] ; } return $ names ; }
Suggest tags by given keyword
@param $keyword
@param int $limit
@return array
Suggest tags by given keyword