예제 #1
0
 public function actionSearchCurrency($search = null, $id = null)
 {
     $out = ['more' => false];
     $q = new Query();
     if (!is_null($search)) {
         $q->select('cur.id, cur.name as text')->from(ResCurrency::tableName() . ' as cur')->where('LOWER(cur.name) LIKE :search')->addParams([':search' => '%' . strtolower($search) . '%']);
         $users = $q->createCommand()->queryAll();
         $out['results'] = array_values($users);
     } elseif ($id > 0) {
         $out['results'] = ['id' => $id, 'text' => ResCurrency::find()->where(['id' => $id])->with('partner')->one()->partner->name];
     } else {
         $out['results'] = ['id' => 0, 'text' => 'No matching records found'];
     }
     echo Json::encode($out);
 }
예제 #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCurrency()
 {
     return $this->hasOne(ResCurrency::className(), ['id' => 'currency_id']);
 }