Commit a5200915 by Angel Martin

Orden de las entradas

parent 9f34fce0
......@@ -17,17 +17,17 @@ class BlogController extends Controller
{
if(isset($request->category)){
$category = Category::where('slug', $request->category)->first();
$posts = $category->entries()->where('status',1)->orderBy('publication_date', 'asc')->paginate(config("blog.blog-index.post-pagination"));
$posts = $category->entries()->where('status',1)->orderBy('publication_date', 'desc')->paginate(config("blog.blog-index.post-pagination"));
} elseif (isset($request->tags)) {
$tags = explode(",", $request->tags);
$posts = Entry::where('status',1)->where(function ($query) use($tags) {
for ($i = 0; $i < count($tags); $i++){
$query->orwhere('tags', 'like', '%' . $tags[$i] .'%');
}
})->orderBy('publication_date', 'asc')->paginate(config("blog.blog-index.post-pagination"));
})->orderBy('publication_date', 'desc')->paginate(config("blog.blog-index.post-pagination"));
} else {
$posts = Entry::where('status',1)->orderBy('publication_date', 'asc')->paginate(config("blog.blog-index.post-pagination"));
$posts = Entry::where('status',1)->orderBy('publication_date', 'desc')->paginate(config("blog.blog-index.post-pagination"));
}
$otros = Entry::where('status',1)->inRandomOrder()->take(config("blog.blog-index.otros"))->get();
$categories = Category::where('active', 1)->get();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment