<?php
namespace frontend\models;
use Yii;
class Users extends \yii\db\ActiveRecord
{
public static function tableName()
{
return 'users';
}
public function rules()
{
return [
[['UID'], 'integer'],
[['dr'], 'safe'],
[['family', 'name', 'otchestvo'],'required'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'UID' => 'Uid',
'family' => 'Фамилия',
'name' => 'Имя',
'otchestvo' => 'Отчество',
'dr' => 'Дата рождения',
];
}
public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
if ($insert) {
Yii::$app->session->setFlash('success', 'Запись добавлена!');
} else {
Yii::$app->session->setFlash('success', 'Запись обновлена!');
}
return true;
} else {
return false;
}
}
/**
* @return \yii\db\ActiveQuery
*/
public function getSnils()
{
return $this->hasMany(Snils::className(), ['users_id' => 'id']);
}
public function getAdres()
{
return $this->hasOne(Adres::className(), ['users_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTelephones()
{
return $this->hasMany(Telephone::className(), ['users_id' => 'id']);
}
}
class Pacients extends ActiveRecord(){
static function tableName(){
return 'pacients';
}
public function getHistory(){
return $this->hasMany(History::className(),['history_id'=>'id']);
}
}
class History extends ActiveRecord
{
static function tableName()
{
return 'history_pacients';
}
public function getPacients(){
return $this->hasOne(System::className(),['id'=>'pacient_id']);
}
public function getNapravlenie(){
return $this->hasOne(Napravlenie::className(),['id'=>'history_id']);
}
}
class Napravlenie extends ActiveRecord
{
static function tableName()
{
return 'napravlenie';
}
public function getHistory(){
return $this->hasMany(History::className(),['history_id'=>'id']);
}
$dataProvider=new ActiveDataProvider([
'query'=>Procedurnay::find()
]);
<button id="ok">OK</button>
<script>
$("#ok").on('click', function() {
alert(22);
})
</script>