/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id = null) { //$posts = Post::all(); $posts = Post::latest('id')->paginate(2); //$posts = DB::table('posts')->paginate(2); return view('post.list', array('posts' => $posts)); }
public function index() { //$posts = Post::all(); //$posts = Post::latest('id')->get(); //$posts = Post::latest('published_at')->get(); $posts = Post::latest('published_at')->where('published_at', '<=', Carbon::now('Europe/Kiev'))->get(); return view('post.index', ['posts' => $posts]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $posts = Post::latest('published_at')->where('published_at', '<=', Carbon::now())->get(); return view('post.index', ['posts' => $posts]); }
/** * Returns the related posts (by category id) * @param type $post * @param type $limit * @return type */ public function getAllRelated($post, $limit = 5) { return Post::latest('published_at')->where('post_type_id', '=', $post->post_type_id)->where('category_id', '=', $post->category_id)->where('id', '!=', $post->id)->take($limit)->get(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $posts = Post::latest()->get(); $tags = Tag::all(); return view('blog.posts', ['posts' => $posts, 'tags' => $tags]); }
public function getPost($id = NULL) { return $id == NULL ? Post::latest()->get() : Post::find($id); }
public function getUnPublishedPosts() { $posts = Post::latest('published_at')->unPublished()->get(); return $posts; }