/var/www/vhosts/nabawater/common/models
Edit: /var/www/vhosts/nabawater/common/models/Ads.php (2430B)
language;
}
$langAlias = "{$alias}L";
$query->leftJoin(
[$langAlias => AdsLang::tableName()],
"$langAlias.ads_id = $alias.ads_id"
)
->andWhere(["$langAlias.language_code" => $language])
->addSelect([
"$langAlias.title as ads_title",
"$langAlias.description as ads_description"
]);
}
/**
* @return array
*/
public function behaviors()
{
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
],
],
];
}
/**
* @return array
*/
public static function getStatusList($typeAsIndex = false)
{
return [
self::STATUS_ACTIVE => 'Active',
self::STATUS_INACTIVE => 'Inactive',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProduct()
{
return $this->hasOne(Item::className(), ['item_id' => 'product_id']);
}
/**
* Get primary key for CGridView
* @return mixed
*/
public function getKey()
{
return $this->ads_id;
}
/**
* Get active ads
* @return \yii\db\ActiveQuery
*/
public static function getActiveAds()
{
return self::find()
->where(['status' => self::STATUS_ACTIVE])
->andWhere(['<=', 'start_date', date('Y-m-d H:i:s')])
->andWhere(['>=', 'end_date', date('Y-m-d H:i:s')]);
}
}