/** * Finds the CsServicesTranslation model based on its translated title. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CsServices the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findServiceByTitle($title) { if (($model_tr = \common\models\CsServicesTranslation::find()->where('name=:name and lang_code="SR"', [':name' => str_replace('-', ' ', $title)])->one()) !== null) { // ako je našao ime usluge, renderuj stranicu - URL injection if ($model_tr and $model = $this->findService($model_tr->service_id)) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Finds the CsServicesTranslation model based on its translated title. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CsServices the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findServiceByTitle($title) { if (($model = \common\models\CsServicesTranslation::find()->where('name=:name and lang_code="SR"', [':name' => str_replace('-', ' ', $title)])->one()) !== null) { $service = $this->findService($model->service_id); return $service; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getTranslation() { $service_translation = CsServicesTranslation::find()->where('lang_code="SR" and service_id=' . $this->id)->one(); if ($service_translation) { return $service_translation; } return false; }
/** * @return \yii\db\ActiveQuery */ public function getServicesTranslations() { return $this->hasMany(CsServicesTranslation::className(), ['lang_code' => 'code']); }