public function api_last($limit = 1) { if ($limit === 1 && $this->_last) { return $this->_last; } $result = []; foreach (GuestbookModel::find()->status(GuestbookModel::STATUS_ON)->sortDate()->limit($limit)->all() as $item) { $result[] = new PostObject($item); } if ($limit > 1) { return $result; } else { $this->_last = count($result) ? $result[0] : null; return $this->_last; } }
public function actionNoanswer() { $this->setReturnUrl(); $data = new ActiveDataProvider(['query' => Guestbook::find()->where(['answer' => ''])->desc()]); return $this->render('index', ['data' => $data]); }