/** * @inheritdoc */ public function load() { $this->resetTable(); $this->data = []; $table = $this->getTableSchema(); $users = User::find()->select(['id'])->column(); if (count($users) > 0) { $index = 0; foreach ($this->getData() as $alias => $row) { $row['id'] = $users[$index++]; $this->db->schema->insert($table->fullName, $row); $this->data[$alias] = $row; } } }
/** * @inheritdoc */ public function load() { $this->resetTable(); $this->data = []; $table = $this->getTableSchema(); $users = User::find()->select(['id'])->column(); if (count($users) > 0) { $index = 0; foreach ($this->getData() as $alias => $row) { if (!isset($users[$index])) { break; } $row['id'] = $users[$index]; $primaryKeys = $this->db->schema->insert($table->fullName, $row); $this->data[$alias] = array_merge($row, $primaryKeys); $index++; } } }
/** * @inheritdoc */ public function load() { $this->resetTable(); $this->data = []; $table = $this->getTableSchema(); $data = $this->getData(); $users = User::find()->select(['id'])->column(); if (count($users) >= 2) { ArrayHelper::multisort($data, 'timestamp', SORT_ASC, SORT_NUMERIC); foreach ($data as $alias => $row) { shuffle($users); $row['sender_id'] = $users[0]; $row['receiver_id'] = $users[1]; $row['created_at'] = date('Y-m-d H:i:s', $row['timestamp']); unset($row['timestamp']); $primaryKeys = $this->db->schema->insert($table->fullName, $row); $this->data[$alias] = array_merge($row, $primaryKeys); } } }
/** * @return ActiveQuery */ public function getContact() { return $this->hasOne(User::className(), ['id' => 'contact_id']); }
public function getUsers(array $except = []) { $users = []; foreach (User::getAll() as $userItem) { $users[] = ['label' => $userItem->name, 'url' => Url::to(['login-as', 'userId' => $userItem->id]), 'options' => ['class' => in_array($userItem->id, $except) ? 'disabled' : ''], 'linkOptions' => ['data-method' => 'post']]; } return $users; }
/** * @return User */ public function getUser() { if (null === $this->_user) { $this->_user = User::findIdentity(\Yii::$app->session->get($this->module->id . '_user', 1)); } return $this->_user; }