- Implementada nueva funcion para crear productos destacados por etiquetas, mostrando carrusel con los mismos en la pagina welcome.
This commit is contained in:
Bryam105
2026-06-02 09:46:53 -03:00
parent 63f91bdd6d
commit 902b8433d9
17 changed files with 480 additions and 33 deletions
+11 -2
View File
@@ -15,9 +15,10 @@ class CatalogoController extends Controller
// 1. Atrapamos lo que el usuario escribió o seleccionó
$query = $request->input('search');
$type = $request->input('type');
$tagFilter = $request->input('tag');
// --- CONSULTA PARA LA GRILLA (PAGINADA) ---
$productsQuery = Product::query();
$productsQuery = Product::with('tags');
$productsQuery->when($query, function ($q) use ($query) {
return $q->where('name', 'like', "%{$query}%");
@@ -29,6 +30,12 @@ class CatalogoController extends Controller
$productsQuery->where('type', '!=', 'service');
}
if ($tagFilter) {
$productsQuery->whereHas('tags', function($q) use ($tagFilter) {
$q->where('name', $tagFilter);
});
}
//mostrar si tiene stock mayor a 0
$productsQuery->where('stock_quantity', '>', 0);
@@ -40,8 +47,10 @@ class CatalogoController extends Controller
->orderBy('name', 'asc')
->get();
$allTags = \App\Models\Tag::orderBy('name')->get();
// Devuelve la vista
return view('catalogo.index', compact('products', 'allProducts'));
return view('catalogo.index', compact('products', 'allProducts', 'allTags'));
}
public function show(Product $product)