Ejemplo n.º 1
0
 /**
  * @param $id
  */
 public function actionViewNotification($id)
 {
     $notification = Notification::findOne([$id]);
     $url = $notification->url;
     $notification->delete();
     $this->redirect($url);
 }
Ejemplo n.º 2
0
 public function viewer($id)
 {
     if (Yii::$app->request->get('notify')) {
         $getid = Yii::$app->request->get('notify');
         //$notification = new Notification();
         $notify = \app\models\Notification::findOne(['type_id' => $id, 'id' => $getid, 'shared_id' => Yii::$app->user->id]);
         $notify->status = 1;
         $notify->save();
     }
     if (Yii::$app->request->get('global')) {
         $getid = Yii::$app->request->get('global');
         //$notification = new Notification();
         $notify = \app\models\Notification::find()->where(['type_id' => $id, 'type' => $getid, 'shared_id' => Yii::$app->user->id, 'status' => 0])->all();
         for ($i = 0; $i < sizeof($notify); $i++) {
             $notify[$i]->status = 1;
             $notify[$i]->save();
         }
     }
     if (Yii::$app->request->get('external')) {
         $getid = Yii::$app->request->get('external');
         $type = Yii::$app->request->get('type');
         //$notification = new Notification();
         $notify = \app\models\Notification::find()->where(['type_id' => $getid, 'type' => $type, 'shared_id' => Yii::$app->user->id, 'status' => 0])->all();
         for ($i = 0; $i < sizeof($notify); $i++) {
             $notify[$i]->status = 1;
             $notify[$i]->save();
         }
     }
     if (Yii::$app->request->get('wishlist')) {
         $getid = Yii::$app->request->get('wishlist');
         //$notification = new Notification();
         $notify = \app\models\Notification::find()->where(['user_id' => $id, 'type' => $getid, 'shared_id' => Yii::$app->user->id, 'status' => 0])->all();
         //var_dump($notify); die();
         for ($i = 0; $i < sizeof($notify); $i++) {
             $notify[$i]->status = 1;
             $notify[$i]->save();
         }
     }
 }
 /**
  * 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.');
     }
 }