/**
  * 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));
 }
Esempio n. 2
0
 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]);
 }
Esempio n. 4
0
 /**
  * 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();
 }
Esempio n. 5
0
 /**
  * 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]);
 }
Esempio n. 6
0
 public function getPost($id = NULL)
 {
     return $id == NULL ? Post::latest()->get() : Post::find($id);
 }
Esempio n. 7
0
 public function getUnPublishedPosts()
 {
     $posts = Post::latest('published_at')->unPublished()->get();
     return $posts;
 }