/var/www/vhosts/nabawater/backend/models
Edit: /var/www/vhosts/nabawater/backend/models/CategoryLang.php (1881B)
yii::t('backend','Sub Category Name'),
];
}
/**
* @return int
*/
protected function translationRelationColumn()
{
return 'category_id';
}
public function uniqueValidation()
{
if(is_array($this->category_name)){
foreach ($this->category_name as $key => $value) {
$model = CategoryLang::find()
->alias('CL')
->innerJoin(['C' => Category::tableName()], 'C.category_id = CL.category_id')
->where([
'CL.category_name' => $this->category_name[$key],
'CL.language_code' => $key
])
->andWhere(['<>', 'C.category_status', Category::DELETE]);
if(!empty($this->category_lang_id[$key])){
$model->andWhere(['<>', 'CL.category_lang_id', $this->category_lang_id[$key]]);
}
$model=$model->one();
if ($model !== null) {
$this->addError("category_name", ''.$this->category_name[$key].' has been already taken',[]);
}
}
}
}
}