Ejemplo n.º 1
0
Archivo: Post.php Proyecto: giicms/tour
 public function getCategory()
 {
     $post = Post::findOne($this->id);
     foreach (explode(',', $post->category_id) as $value) {
         $category = Category::findOne($value);
         if (!empty($category)) {
             $data[] = ['id' => $category->id, 'parent_id' => $category->parent_id, 'title' => $category->title, 'indent' => $this->getIndent($category->indent)];
         }
     }
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Post the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Post::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }