本文整理汇总了PHP中app\models\Post::latest方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::latest方法的具体用法?PHP Post::latest怎么用?PHP Post::latest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Post
的用法示例。
在下文中一共展示了Post::latest方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* 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));
}
示例2: index
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]);
}
示例3: index
/**
* 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]);
}
示例4: getAllRelated
/**
* 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();
}
示例5: index
/**
* 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]);
}
示例6: getPost
public function getPost($id = NULL)
{
return $id == NULL ? Post::latest()->get() : Post::find($id);
}
示例7: getUnPublishedPosts
public function getUnPublishedPosts()
{
$posts = Post::latest('published_at')->unPublished()->get();
return $posts;
}