本文整理汇总了PHP中yii\db\ActiveRecord::afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::afterSave方法的具体用法?PHP ActiveRecord::afterSave怎么用?PHP ActiveRecord::afterSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::afterSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterSave
public function afterSave($insert, $changedAttributes)
{
$this->preview_input = UploadedFile::getInstance($this, 'preview_input');
if (!empty($this->preview_input)) {
$this->preview_input->saveAs($this->preview_picture);
}
parent::afterSave($insert, $changedAttributes);
}
示例2: afterSave
public function afterSave($insert, $changedAttributes)
{
if ($insert === true) {
Siteinfo::updateCounterInfo('addNode');
}
return parent::afterSave($insert, $changedAttributes);
}
示例3: afterSave
/**
* —охран¤ем данные в кеш
* @param bool $insert
* @param array $changedAttributes
*/
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
//$command = new SaveInCache();
//$command->setData($this->attributes)
// ->execute();
}
示例4: afterSave
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
// die;
/* $priority range low =1 normal =2 high=3*/
//background($name, $data = null, $priority = self::NORMAL, $unique = null)
Yii::$app->gearman->getDispatcher()->background('mailJob', new JobWorkload(['params' => ['data' => $this->id]]), $this->priority);
}
示例5: afterSave
public function afterSave($insert, $changedAttributes)
{
//$oldCategorias = array("0"=>1);
$actualAssignments = [];
if (($actualAssignments = AuthAssignment::find()->andWhere("user_id = {$this->id}")->asArray()->all()) !== null) {
$actualAssignments = ArrayHelper::getColumn($actualAssignments, 'item_name');
}
//verifica se é um array
$this->assignmentIds = is_array($this->assignmentIds) ? $this->assignmentIds : [$this->assignmentIds];
$inserirAssignments = array_diff($this->assignmentIds, $actualAssignments);
if (!empty($inserirAssignments)) {
//save the relations
foreach ($inserirAssignments as $id) {
$r = new AuthAssignment();
$r->user_id = $this->id;
$r->item_name = $id;
$r->save();
}
}
$delAssignments = array_diff($actualAssignments, $this->assignmentIds);
if (!empty($delAssignments)) {
foreach ($delAssignments as $remove) {
$r = AuthAssignment::findOne(['item_name' => $remove, 'user_id' => $this->id]);
$r->delete();
}
}
parent::afterSave($insert, $changedAttributes);
//don't forget this
}
示例6: afterSave
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
if ($insert) {
$this->getProvince();
}
}
示例7: afterSave
public function afterSave($insert, $changedAttributes)
{
//$oldCategorias = array("0"=>1);
$actualItens = [];
if (($actualItens = AuthItemChild::find()->andWhere("parent = '{$this->name}'")->asArray()->all()) !== null) {
$actualItens = ArrayHelper::getColumn($actualItens, 'child');
}
//verifica se é um array
$this->itemIds = is_array($this->itemIds) ? $this->itemIds : [$this->itemIds];
$inserirItens = array_diff($this->itemIds, $actualItens);
if (!empty($inserirItens)) {
//save the relations
foreach ($inserirItens as $id) {
$r = new AuthItemChild();
$r->parent = $this->name;
$r->child = $id;
$r->save();
}
}
$delItens = array_diff($actualItens, $this->itemIds);
if (!empty($delItens)) {
foreach ($delItens as $remove) {
$r = AuthItemChild::findOne(['child' => $remove, 'parent' => $this->name]);
$r->delete();
}
}
parent::afterSave($insert, $changedAttributes);
//don't forget this
}
示例8: afterSave
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
if ($this->value == '') {
$this->delete();
}
}
示例9: afterSave
/**
* @inheritdoc
*/
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
$domain = preg_split("/\r\n/isU", trim($this->domain_txt));
$site_id = $this->getPrimaryKey();
$domains = Domain::find()->where(['site_id' => $site_id])->all();
foreach ($domain as $key => $dm) {
$dm = trim($dm);
if (empty($dm)) {
continue;
}
$domain_model = $this->findModelByDomain($domains, $dm);
if (!isset($domain_model)) {
$domain_model = new Domain();
}
if ($key === 0) {
$domain_model->main = 1;
} else {
$domain_model->main = 0;
}
$domain_model->domain = $dm;
$domain_model->site_id = $this->id;
$domain_model->save();
}
}
示例10: afterSave
/**
* @inheritdoc
*/
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
// if onSite was changed in the form
if ($this->onSite == empty($this->travel)) {
if ($this->onSite) {
$this->link('travel', new Travel());
} else {
$this->unlink('travel', $this->travel, true);
}
}
// compile an array with [note_id => ticket_id] for each ticket currently attached
$note_to_ticket = ArrayHelper::map($this->notes, 'id', 'ticket_id');
// are we updating an existing event?
if (!$insert) {
// get a list of all tickets that need to be removed from event
$removeNotes = array_keys(array_diff($note_to_ticket, $this->ticketIds));
Note::deleteAll(['id' => $removeNotes, 'author_id' => null]);
Labor::deleteAll(['schedule_id' => $this->id, 'note_id' => $removeNotes, 'hours' => null]);
}
// get a list of all the tickets to add and attach them to the event
foreach (array_diff($this->ticketIds, $note_to_ticket) as $ticket_id) {
$note = new Note(['scenario' => Note::SCENARIO_SCHEDULE, 'ticket_id' => $ticket_id]);
$note->save(false);
$this->link('notes', $note);
// update the ticket status if still submitted
if ($note->ticket->status_id == Ticket::STATUS_SUBMITTED) {
$note->ticket->status_id = Ticket::STATUS_IN_PROGRESS;
$note->ticket->save(false);
}
}
}
示例11: afterSave
public function afterSave($insert, $changedAttributes)
{
if ($insert) {
AttachmentFile::updateAll(['status_id' => AttachmentFile::STATUS_PERMANENT], ['id' => $this->attachment_id]);
}
parent::afterSave($insert, $changedAttributes);
}
示例12: afterSave
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
if (isset($changedAttributes['is_active']) && $changedAttributes['is_active'] != self::FINISHED && $this->is_active == self::FINISHED) {
News::updateAll(['archive' => News::ARCHIVE_TRUE], ['id_tournament' => $this->id_tournament]);
//assigning Events for winners forecast
Top3TeamsForecast::setEventForTournament($this->id_tournament);
//adding additional points to the total points field of UserTournaments model
$this->assignAdditionalPoints();
}
//if setting tournament back to active from finished, need to remove calculated additional points and clean additional forecast events
if (isset($changedAttributes['is_active']) && $changedAttributes['is_active'] == self::FINISHED && $this->is_active == self::GOING) {
//removing additional points to the total points field of UserTournaments model
$this->removeAdditionalPoints();
//assigning Events for winners forecast to NULL
Top3TeamsForecast::clearEventForTournament($this->id_tournament);
}
if ($insert) {
$news = new News();
$news->scenario = 'send';
$news->id_tournament = 0;
$news->subject = 'Добавлен новый турнир';
$news->body = "<p>Для прогноза доступен новый турнир {$this->tournament_name}, первый тур которого состоится " . date('d.m.y', $this->startsOn) . " </p>" . "<p>Вы также можете попробовать угадать призеров турнира и заработать дополнительные очки! Прогноз на призеров принимается до " . date('d.m.y', $this->wfDueTo) . " </p>" . "<p>Спешите принять участие! Зайдите в <strong>Профиль->Мои турниры</strong> чтобы начать делать прогнозы</p>";
$news->save();
}
}
示例13: afterSave
public function afterSave($insert, $changedAttributes)
{
foreach ($this->order->items as $item) {
$item->save();
}
return parent::afterSave($insert, $changedAttributes);
}
示例14: afterSave
public function afterSave($insert, $changedAttributes)
{
if ($insert) {
// Да это новая запись (insert)
$model = new LogReestr();
$model->resstr = 'apteki';
$model->id_resstr = $this->id;
$model->address = $this->address;
$model->ur_l_id = $this->ur_l_id;
$model->action = 'insert';
$model->user = Yii::$app->user->identity->id;
$model->save();
} else {
// Нет, старая (update)
$save = "";
foreach ($changedAttributes as $change => $val) {
if (trim($val) != trim($this->{$change})) {
$save .= $this->attributeLabels()[$change] . '[' . $val . '->' . $this->{$change} . "]\n";
}
}
if ($save != "") {
$model = new LogReestr();
$model->resstr = 'apteki';
$model->id_resstr = $this->id;
$model->address = $this->address;
$model->ur_l_id = $this->ur_l_id;
$model->action = 'update';
$model->change = $save;
$model->user = Yii::$app->user->identity->id;
$model->save();
}
}
parent::afterSave($insert, $changedAttributes);
}
示例15: afterSave
/**
* @inheritdoc
*/
public function afterSave($insert, $changedAttributes)
{
if ($this->default) {
$this->setLanguageDefault();
}
parent::afterSave($insert, $changedAttributes);
}