/** * Display the specified resource. * * @param $slug * @param Request $request * * @return \Illuminate\Http\Response */ public function showPost($slug, Request $request) { $post = Post::with('tags')->whereSlug($slug)->firstOrFail(); $tag = $request->get('tag'); $title = $post->title; if ($tag) { $tag = Tag::whereTag($tag)->firstOrFail(); } $data = ['post' => $post, 'tag' => $tag, 'title' => $title]; return view($post->layout, $data); }
/** * Display a listing of the posts. * * @return \Illuminate\View\View */ public function index() { $data = Post::with('author')->get(); return view('easel::backend.post.index', compact('data')); }
/** * @param $author_id * * @return array */ public function postsByAuthorId($author_id) { $posts = Post::with('tags')->where('author_id', '=', $author_id)->where('published_at', '<=', Carbon::now())->where('is_draft', 0)->orderBy('published_at', 'desc')->simplePaginate(config('easel.posts_per_page')); return $this->assemblePostData($posts); }