Пример #1
0
 /**
  * @establish a relationship with client or website model
  */
 public function getCow()
 {
     if ($this->belong_to == 1) {
         return $this->hasOne(Client::className(), ['id' => 'clients_or_webs_id']);
     } elseif ($this->belong_to == 2) {
         return $this->hasOne(Website::className(), ['id' => 'clients_or_webs_id']);
     }
 }
Пример #2
0
 public function getWebsite()
 {
     return $this->hasOne(Website::className(), ['WebsiteID' => 'WebsiteID']);
 }