Exemple #1
0
 public function getCarName()
 {
     $name = '';
     if ($this->brand_id) {
         $name = $name . ' ' . AutoBrands::findOne($this->brand_id)->name;
     }
     if ($this->model_id) {
         $name = $name . ' ' . AutoModels::findOne($this->model_id)->name;
     }
     if (empty($name)) {
         $name = $this->name;
     }
     if ($this->year) {
         $name = $name . ' ' . $this->year . 'г.';
     }
     return $name;
 }
Exemple #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBrand()
 {
     return $this->hasOne(AutoBrands::className(), ['id' => 'brand_id']);
 }