Commit 4ec49b28 by Francisco Salazar

product order desc

parent 8fe2e5d0
......@@ -17,10 +17,10 @@ class ProductController extends Controller
if(isset($request->category)){
$category = Category::where('slug', $request->category)->first();
$products = $category->products()->where('active', true)->paginate(config("product.product-index."));
$products = $category->products()->where('active', true)->orderBy('created_at', 'desc')->paginate(config("product.product-index."));
} else {
$products = Product::where('active', true)->paginate(config("product.product-index.pagination"));
$products = Product::where('active', true)->orderBy('created_at', 'desc')->paginate(config("product.product-index.pagination"));
}
$otros = Product::where('active', true)->inRandomOrder()->take(config("product.product-index.otros"))->get();
$categories = Category::where('active', true)->get();
......@@ -58,7 +58,7 @@ class ProductController extends Controller
public function byCategory($category_slug)
{
$category = Category::where('slug', $category_slug)->first();
$products = $category->products()->where('active', true)->paginate(config("product.product-bycategory.pagination"));
$products = $category->products()->where('active', true)->orderBy('created_at', 'desc')->paginate(config("product.product-bycategory.pagination"));
$otros = Product::where('active', true)->inRandomOrder()->take(config("product.product-bycategory.otros"))->get();
$categories = Category::where('active', true)->get();
......@@ -75,7 +75,7 @@ class ProductController extends Controller
//return $category_slug . " " .$subcategory_slug;
$category = Category::where('slug', $category_slug)->first();
$subcategory = $category->subcategories->where('slug', $subcategory_slug)->first();
$products = $subcategory->products()->where('active', true)->paginate(config("product.product-bysubcategory.pagination"));
$products = $subcategory->products()->where('active', true)->orderBy('created_at', 'desc')->paginate(config("product.product-bysubcategory.pagination"));
$otros = Product::where('active', true)->inRandomOrder()->take(config("product.product-bycategory.otros"))->get();
$categories = Category::where('active', true)->get();
......
......@@ -10,7 +10,9 @@ Listado de entradas
<p>
Productos todas
{{$products}}
@foreach($products as $product)
{{$product}}
@endforeach
</p>
<p>
......
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