Exemplo n.º 1
0
 public function actionIndex()
 {
     //$page = new Pages();
     $news = News::find()->where(['status' => '1'])->orderBy('id DESC')->limit(4)->all();
     $guest = GuestBook::find()->where(['status' => '1'])->orderBy('id DESC')->limit(4)->all();
     $pages = Pages::find()->where(['page' => 'home'])->one();
     return $this->render('index', ['page' => $pages, 'news' => $news, 'guest' => $guest]);
 }
Exemplo n.º 2
0
 public function actionIndex()
 {
     $model = new GuestBook();
     $guest_row = $model->find()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->refresh();
     } else {
         return $this->render('index', ['model' => $model, 'guest_row' => $guest_row]);
     }
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = GuestBook::find();
     $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, 'parent_id' => $this->parent_id, 'created_at' => $this->created_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'message', $this->message]);
     return $dataProvider;
 }
Exemplo n.º 4
0
 /**
  * Lists all GuestBook models.
  * @return mixed
  */
 public function actionIndex()
 {
     // $searchModel = new GuestBookSearch();
     // $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $model = GuestBook::find()->all();
     $timeline_items = [];
     $events = [];
     foreach ($model as $key => $value) {
         $time = $value->created_at;
         $footer = '<a class="btn btn-warning btn-flat btn-xs">View comment</a>' . '<a href="#" class="btn btn-xs bg-maroon">See comments</a>' . '<a class="btn btn-primary btn-xs">Read more</a>' . '<a class="btn btn-danger btn-xs">Delete</a>';
         $obj = Yii::createObject(['class' => \insolita\wgadminlte\ExampleTimelineItem::className(), 'time' => $value->created_at, 'header' => '<i class="fa fa-user"></i> ' . $value->username . ' |  <i class="fa fa-envelope"></i> ' . $value->email, 'body' => $value->message, 'type' => 1, 'footer' => $footer, 'iconClass' => 'fa fa-envelope']);
         $events[] = $obj;
     }
     $timeline_items[$time] = $events;
     return $this->render('index', ['timeline_items' => $timeline_items]);
 }