Esempio n. 1
0
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $kategory_forum = Yii::$app->session['forum_id'];
     $posting = Post::find()->where(['kategory_forum' => $kategory_forum])->all();
     $forum = Forum::find()->where(['id' => $kategory_forum])->one();
     $nama = "";
     foreach ($posting as $postings) {
         $nama = $postings->nama;
     }
     $usr = new \common\models\User();
     $fotoPost = $usr->find()->where(['nama' => $nama])->all();
     return $this->render('index', ['posting' => $posting, 'forum' => $forum, 'fotoPost' => $fotoPost]);
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Forum::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', 'nama', $this->nama]);
     return $dataProvider;
 }
Esempio n. 3
0
 /**
  * Finds the Forum model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Forum the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Forum::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getKategoryForum()
 {
     return $this->hasOne(Forum::className(), ['id' => 'kategory_forum']);
 }