public function update(Request $request, $id) { $notification = \App\Models\Notification::find($id); $notification->fill($request->all()); $notification->save(); return view('notifications', ['notifications' => $notifications]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Notification::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'userUpdate' => $this->userUpdate, 'userCreate' => $this->userCreate, 'updateDate' => $this->updateDate, 'createDate' => $this->createDate]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'message', $this->message])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'params', $this->params]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Notification::find()->where(['shared_id' => Yii::$app->user->id]); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'type_id' => $this->type_id, 'status' => $this->status, 'date' => $this->date]); $query->andFilterWhere(['like', 'shared_id', $this->shared_id])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'type', $this->type]); return $dataProvider; }
public function actionGetpostnotification() { $studentID = $_POST['studentID']; $model = array(); $value = "0"; $model = Notification::find()->where(['notified' => $studentID, 'seen' => $value])->all(); // $model=Notification::findAll ((['notified'=>$studentID]) & (['seen' =>$value]) ); $status = array(); if ($model == Null) { $status["status"] = "null"; } else { for ($i = 0; $i < sizeof($model); $i++) { $status["status"] = "ok"; $status["type"][$i] = $model[$i]->type; $status["postID"][$i] = $model[$i]->postID; $status["sender"][$i] = $model[$i]->sender; } } return json_encode($status); }
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(); } } }
/** * @return newsfeed generations array- DTR */ public function getNews() { $user = Yii::$app->user->id; $notification = Notification::find()->where(['shared_id' => $user])->orderBy(['date' => SORT_DESC])->all(); foreach ($notification as $news) { if ($news->type == 'event') { return Event::find()->where(['id' => $news->type_id]); } elseif ($news->type == 'activity') { return Activity::find()->where(['id' => $news->type_id]); } elseif ($news->type == 'journal') { return Journal::find()->where(['id' => $news->type_id]); } elseif ($news->type == 'wishlist') { return Wishlist::find()->where(['id' => $news->type_id]); } else { return Photos::find()->where(['id' => $news->type_id]); } } }
public function findById($id) { return Notification::find($id)->first(); }
public function actionSample() { //$objPHPExcel = new \PHPExcel(); $template = Yii::$app->util->templateExcel(); $model = new Notification(); $date = date('YmdHis'); $name = $date . Notification; //$attributes = $model->attributeLabels(); $models = Notification::find()->all(); $excelChar = Yii::$app->util->excelChar(); $not = Yii::$app->util->excelNot(); foreach ($model->attributeLabels() as $k => $v) { if (!in_array($k, $not)) { $attributes[$k] = $v; } } $objReader = \PHPExcel_IOFactory::createReader('Excel5'); $objPHPExcel = $objReader->load(Yii::getAlias($template)); return $this->render('sample', ['models' => $models, 'attributes' => $attributes, 'excelChar' => $excelChar, 'not' => $not, 'name' => $name, 'objPHPExcel' => $objPHPExcel]); }
private function _validate($id) { if ($id == null) { return false; } $data = Notification::find($id); if (!$data) { return false; } return $data; }
use yii\bootstrap\Nav; use yii\bootstrap\NavBar; use yii\helpers\Html; use yii\helpers\Url; use yii\widgets\Breadcrumbs; AppAsset::register($this); $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> "> <head> <?php $notifications = Notification::find()->where(['user_id' => Yii::$app->user->id]); $this->title = $notifications->count() == 0 ? $this->title : '(' . $notifications->count() . ') ' . $this->title; ?> <meta charset="<?php echo Yii::$app->charset; ?> "> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php echo Html::csrfMetaTags(); ?> <title><?php echo Html::encode($this->title); ?> </title> <?php