Example #1
0
 public static function getOneOrDefault($takonomy)
 {
     $takonomyModel = Takonomy::findOne(['id' => $takonomy]);
     if ($takonomyModel === null) {
         $takonomyModel = ['id' => null, 'name' => '所有'];
     }
     return $takonomyModel;
 }
Example #2
0
 public function actionIndex()
 {
     $takonomy = LuLu::getGetValue('takonomy');
     $query = Content::find();
     $query->where(['content_type' => $this->content_type]);
     $query->andFilterWhere(['takonomy_id' => $takonomy]);
     if ($takonomy === null) {
         $takonomyModel = Takonomy::findOne(['id' => $takonomy]);
     } else {
         $takonomyModel = ['id' => null, 'name' => '所有'];
     }
     $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => 10]);
     $locals['takonomyModel'] = $takonomyModel;
     return $this->render('index', $locals);
 }
Example #3
0
 /**
  * Finds the Takonomy model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Takonomy the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Takonomy::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }