public function index()
 {
     $recordings = $this->model->all()->where('alias', $this->alias);
     if (Entrust::hasRole('admin')) {
         $rec_guest = Guestbook::with('user')->get();
     } else {
         $rec_guest = null;
     }
     return view($this->alias . '.index', ['recordings' => $recordings, 'alias' => $this->alias, 'model' => null, 'rec_guest' => $rec_guest]);
 }
 /**
  * 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]);
     $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'address', $this->address]);
     return $dataProvider;
 }
 public function index()
 {
     $guestbook = Guestbook::latest()->paginate(50);
     return view('admin.index', compact('guestbook'));
 }
 /**
  * Finds the Guestbook model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Guestbook the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Guestbook::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }