public function readPost($request) { try { $post = $this->db->fetchOne(BlogPost::where('created')->between($from, $to)->and('slug')->equals($request->params['slug'])); } catch (Minim_Model_Exception $e) { // 404 } $this->render('post-read', array('title' => $post->title, 'content' => $post->content, 'created' => $post->created->format('d/m/Y \\a\\t H:i'), 'author' => $post->author)); }
/** * Tworzenie struktury związku * @param Post $post * @param Category $category * @param array $params dodatkowe parametry * @return Collection */ public static function getStructure(Post $post, Category $category, array $params = []) { $structure = null; $categories = $category->getSubcategories(false, true); if ($categories) { $structure = Category::orderByRaw('"order" asc NULLS LAST')->find($categories)->filter(function ($elem) use($post) { if (empty($elem->communication) === false) { $post = BlogPost::where('id', $elem->communication)->first(); $elem->communication = $post->getPaths(); } $elem->posts = BlogPost::getPosts(['categories_id' => [$elem->id], 'template_id' => 2, 'additional' => ['person_type' => 3], 'order' => "additional->>'order' NULLS LAST"]); return $elem->posts->count() > 0; }); } return $structure; }
/** * Display the specified resource. * * @param string $slug * @return Response */ public function show($slug) { if (is_null($blog_post = BlogPost::where('slug', $slug)->first())) { // Put a 404 in ur face, yo ! return App::abort(404); } return View::make('modules.blog.posts.show', compact('blog_post')); }