<?php

namespace common\modules\blog\models;

use common\modules\languages\models\Languages;

/**
 * This is the ActiveQuery class for [[PostTag]].
 *
 * @see PostTag
 */
class PostTagQuery extends \yii\db\ActiveQuery
{
    public function currentLang()
    {
        $lang = Languages::getCurrent();

        if($lang->default)
        {
            return $this->andWhere('lang_id = '.$lang->id.' OR lang_id IS NULL');
        }
        
        return $this->andWhere([
            'lang_id' => $lang->id
        ]);
    }

    /**
     * @inheritdoc
     * @return PostTag[]|array
     */
    public function all($db = null)
    {
        return parent::all($db);
    }

    /**
     * @inheritdoc
     * @return PostTag|array|null
     */
    public function one($db = null)
    {
        return parent::one($db);
    }
}
