/var/www/vhosts/nabawater/backend/models
Edit: /var/www/vhosts/nabawater/backend/models/UnitLang.php (1862B)
yii::t('backend','Unit Name'),
];
}
/**
* @return int
*/
protected function translationRelationColumn()
{
return 'unit_id';
}
public function uniqueValidation()
{
if(is_array($this->unit_name)){
foreach ($this->unit_name as $key => $value) {
if(strlen($this->unit_name[$key])>50){
$this->addError("unit_name", ''.'unit Name must contain 50 chars only',[]);
}
$model = UnitLang::find()
->alias('BL')
->innerJoin(['B' => Unit::tableName()], 'B.unit_id = BL.unit_id')
->where([
'BL.unit_name' => ltrim($this->unit_name[$key]),
'BL.language_code' => $key
])
->andWhere(['<>', 'B.unit_status', Unit::DELETE]);
if(!empty($this->brand_lang_id[$key])){
$model->andWhere(['<>', 'BL.unit_lang_id', $this->unit_lang_id[$key]]);
}
$model=$model->one();
if ($model !== null) {
$this->addError("unit_name", ''.$this->unit_name[$key].' has been already taken',[]);
}
}
}
}
}