Example #1
0
 public function read(Application $app, $id, $slug)
 {
     try {
         $post = Post::with('author', 'children', 'children.author')->findOrFail($id);
     } catch (ModelNotFoundException $e) {
         return Theme::view('errors/not_found');
     }
     if ($slug != $post->slug) {
         return $app->redirect($app->path('site.post.read', ['id' => $id, 'slug' => $post->slug]));
     }
     if (!$post->board->userHasAccess()) {
         return Theme::view('errors/access_denied');
     }
     return Theme::view('post', ['post' => $post->toArray()]);
 }
Example #2
0
 /**
  * Get posts for template display
  * 
  * @return array
  */
 public static function posts($boards = array())
 {
     $boards = (new Collection($boards))->pluck('id')->all();
     return Post::where('parent_id', null)->whereIn('board_id', $boards)->with('board', 'author')->get()->toArray();
 }