/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Families::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('wife');
     $query->andFilterWhere(['id' => $this->id, 'husband_id' => $this->husband_id, 'wife_id' => $this->wife_id, 'mdate' => $this->mdate, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'descr', $this->descr])->andFilterWhere(['like', 'wife.sname', $this->wife_id])->andFilterWhere(['like', 'wife.fname', $this->wife_id]);
     return $dataProvider;
 }
 /**
  * Finds the Families model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Families the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Families::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #3
0
 /**
  * 
  * @param type $id
  */
 public static function getFamilies($id)
 {
     $families = Families::find()->where(['wife_id' => $id])->orWhere(['husband_id' => $id])->all();
     return $families;
 }
Exemple #4
0
    $spouseName = Relatives::findOne($spouse);
    echo Html::beginTag('table', ['class' => 'table table-striped table-bordered detail-view']);
    echo Html::beginTag('tr', ['class' => 'info']);
    $father = $families[$i]->husband_id;
    $mother = $families[$i]->wife_id;
    $url = '/relatives/create?father_id=' . $father . '&mother_id=' . $mother;
    $options = NULL;
    $text = Html::tag('a', '<small>Добавить ребёнка</small>', ['class' => 'btn btn-success pull-right', 'href' => $url, 'target' => '_blank']);
    $a = Html::a('<h4>Семья</h4>', '/family/default/view?id=' . $families[$i]->id, ['target' => '_blank']);
    echo Html::tag('th', $a . $text, ['colspan' => COL_SPAN]);
    echo Html::endTag('tr');
    echo Html::beginTag('tr');
    echo Html::tag('th', 'Супруг(а)', ['colspan' => COL_SPAN]);
    echo Html::endTag('tr');
    Relatives::renderRow($spouse);
    $fam = Families::findOne($families[$i]->id);
    $children = $fam->getChildren();
    if ($children) {
        echo Html::beginTag('tr');
        echo Html::tag('th', 'Дети', ['colspan' => COL_SPAN]);
        echo Html::endTag('tr');
        foreach ($children as $child) {
            Relatives::renderRow($child->id);
        }
    }
    echo Html::endTag('table');
}
if ($model->gender) {
    $field = 'mother_id';
    $nullField = 'father_id';
} else {