/** * Finds the Notification model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Notification the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Notification::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionHideNotifiAjax($id) { $model = Notification::findOne($id); if ($model && $model->uid == Yii::$app->user->id) { $model->hide = 1; $model->save(); } }
/** * 查找用户的动作通知 * @param UserMeta $meta * @return null|static */ public function findUserActionNotify(UserMeta $meta) { if ($meta->target_type == 'comment') { $condition['comment_id'] = $meta->target_id; } else { $condition['post_id'] = $meta->target_id; } return Notification::findOne(['from_user_id' => $meta->user_id, 'type' => $meta->target_type . '_' . $meta->type] + $condition); }