本文整理匯總了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;
}