/** * Get latest posts * * @param $total * @return mixed */ public function getLatest($total = 10) { $total = $total > 0 && $total <= 100 ? $total : 10; return Post::with('author', 'category')->orderBy('created_at')->take($total)->get(); }