php artisan migrate:fresh y php artisan importar:excel, les tengo que pasar el archivo csv

This commit is contained in:
gianella
2026-04-04 20:59:30 -03:00
parent d1467ca098
commit b4476431e4
9 changed files with 224 additions and 61 deletions
+49 -9
View File
@@ -35,24 +35,64 @@
</style>
@endpush
<x-section-header subtitle="Inicio" title="Catalogo de " highlight="Productos"/>
<x-section-header subtitle="Inicio" title="Catálogo de " highlight="Productos"/>
<div class="w-full max-w-5xl mx-auto px-4">
<div class="mb-8 bg-stone-200/30 dark:bg-neutral-950/30 p-5 rounded-xl border border-neutral-200 dark:border-neutral-800">
<!-- BLOQUE 1: Búsqueda rápida con Select2 (Te lleva directo al producto) -->
<div class="mb-4 bg-stone-200/30 dark:bg-neutral-950/30 p-5 rounded-xl border border-neutral-200 dark:border-neutral-800">
<label for="buscador-catalogo" class="block text-sm font-semibold text-gray-800 dark:text-gray-300 mb-2">
Búsqueda rápida por similitud
Salto rápido a producto específico
</label>
<select id="buscador-catalogo" class="w-full">
<option value="">Escribe para buscar un producto...</option>
@foreach ($allProducts as $p)
<option value="{{ route('catalogo.show', $p->id) }}">
{{ $p->description }} - ${{ number_format($p->price, 2, ',', '.') }}
{{ $p->name }} - ${{ number_format($p->price, 2, ',', '.') }}
</option>
@endforeach
</select>
</div>
<!-- BLOQUE 2: Filtros de la Grilla -->
<form action="{{ route('catalogo.index') }}" method="GET" class="mb-8 flex flex-col md:flex-row gap-3 bg-stone-200/30 dark:bg-neutral-950/30 p-4 rounded-xl border border-neutral-200 dark:border-neutral-800">
<div class="relative w-full md:w-1/2">
<input type="text" name="search" value="{{ request('search') }}"
class="block w-full p-3 text-sm text-black dark:text-white border border-neutral-400 dark:border-neutral-700 rounded-lg bg-white dark:bg-neutral-900 placeholder-gray-600 dark:placeholder-gray-500 focus:ring-neon-lime focus:border-neon-lime"
placeholder="Buscar en el catálogo...">
</div>
<div class="w-full md:w-1/3">
<select name="type" onchange="this.form.submit()"
class="block w-full p-3 text-sm text-black dark:text-white border border-neutral-400 dark:border-neutral-700 rounded-lg bg-white dark:bg-neutral-900 focus:ring-neon-lime focus:border-neon-lime cursor-pointer">
<option value="">Todas las Categorías</option>
<option value="bike" {{ request('type') == 'bike' ? 'selected' : '' }}>Bicicletas</option>
<option value="clothing" {{ request('type') == 'clothing' ? 'selected' : '' }}>Indumentaria</option>
<option value="accessory" {{ request('type') == 'accessory' ? 'selected' : '' }}>Accesorios</option>
<option value="spare" {{ request('type') == 'spare' ? 'selected' : '' }}>Repuestos</option>
<option value="children" {{ request('type') == 'children' ? 'selected' : '' }}>Infantil</option>
<option value="rollers" {{ request('type') == 'rollers' ? 'selected' : '' }}>Rollers</option>
<option value="skate" {{ request('type') == 'skate' ? 'selected' : '' }}>Skate</option>
<option value="other" {{ request('type') == 'other' ? 'selected' : '' }}>Otros</option>
</select>
</div>
<div class="flex gap-2">
<button type="submit" class="px-5 py-3 text-sm font-bold text-neutral-900 bg-neon-lime rounded-lg hover:bg-[#b3e600] transition-colors">
Filtrar
</button>
@if(request('search') || request('type'))
<a href="{{ route('catalogo.index') }}" title="Limpiar Filtros" class="flex items-center justify-center p-3 text-sm font-bold text-red-600 bg-red-100 dark:bg-red-900/30 rounded-lg hover:bg-red-200 transition-colors">
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18 17.94 6M18 18 6.06 6"/>
</svg>
</a>
@endif
</div>
</form>
<!-- GRILLA DE PRODUCTOS -->
@if ($products->count() > 0)
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
@foreach ($products as $product)
@@ -60,7 +100,7 @@
{{-- Imagen si existe --}}
@if (!empty($product->image_path))
<img src="{{ asset('storage/' . $product->image_path) }}" alt="{{ $product->description }}"
<img src="{{ asset('storage/' . $product->image_path) }}" alt="{{ $product->name }}"
class="w-full h-40 object-cover rounded mb-4">
@else
<div class="w-full border border-neutral-200 dark:border-neutral-800 h-40 bg-stone-200 dark:bg-stone-900 flex items-center justify-center rounded mb-4">
@@ -78,14 +118,14 @@
{{-- Botón --}}
<a href="{{ route('catalogo.show', $product->id) }}"
class="mt-4 block w-full bg-neutral-900 dark:bg-neon-lime/80 uppercase text-neon-lime dark:text-black font-semibold py-2 rounded-lg text-center shadow-md shadow-gray-900/10 dark:shadow-neon-lime/10 hover:bg-neon-lime hover:dark:bg-neutral-900/70 border border-transparent hover:text-black hover:dark:text-neon-lime hover:border-black hover:dark:border-neon-lime transition-all">
Ver +
Ver Detalle
</a>
</div>
@endforeach
</div>
@else
<p class="text-center text-gray-400 dark:text-gray-600 mt-10">No hay productos disponibles.</p>
<p class="text-center text-gray-600 dark:text-gray-400 mt-10 font-medium">No se encontraron productos con esos filtros.</p>
@endif
<div class="mt-8">
@@ -106,12 +146,12 @@
width: '100%'
});
// 2. Evento: Cuando el usuario hace clic en una opción de la lista
// 2. Evento: Cuando el usuario hace clic en una opción de la lista Select2
$('#buscador-catalogo').on('select2:select', function (e) {
let urlDestino = $(this).val();
if (urlDestino) {
// Redirigimos a la página del producto
// Redirigimos a la página del detalle del producto
window.location.href = urlDestino;
}
});
+55 -18
View File
@@ -5,44 +5,77 @@
<!-- Mensajes de feedback -->
<x-ui.alert />
<!-- Barra de Herramientas (Buscador + Botón Crear) -->
<div class="w-full flex flex-col md:flex-row justify-between items-center gap-4 mb-6">
<!-- Buscador -->
<form action="{{ route('productos.index') }}" method="GET" class="w-full lg:w-2/3 flex flex-col sm:flex-row gap-3">
<div class="relative w-full sm:w-2/3">
<!-- Barra de Herramientas (Buscador + Botones) -->
<div class="w-full flex flex-col xl:flex-row justify-between items-start xl:items-center gap-4 mb-6">
<!-- Buscador y Filtros -->
<form action="{{ route('productos.index') }}" method="GET" class="w-full xl:w-4/5 flex flex-col md:flex-row gap-3">
<!-- 1. Buscador por Texto -->
<div class="relative w-full md:w-2/5">
<div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
<svg class="w-4 h-4 text-gray-600 dark:text-gray-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
</svg>
</div>
<input type="text" name="search" value="{{ request('search') }}"
class="block w-full p-3 ps-10 text-sm text-black dark:text-white border border-neutral-400 dark:border-neutral-700 rounded-lg bg-neutral-200 dark:bg-neutral-800 placeholder-gray-600 dark:placeholder-gray-500"
placeholder="Buscar por nombre, SKU o marca...">
class="block w-full p-3 ps-10 text-sm text-black dark:text-white border border-neutral-400 dark:border-neutral-700 rounded-lg bg-neutral-200 dark:bg-neutral-800 placeholder-gray-600 dark:placeholder-gray-500 focus:ring-neon-lime focus:border-neon-lime"
placeholder="Buscar por nombre">
</div>
<!-- Filtro de Estado de Stock -->
<div class="w-full sm:w-1/3">
<select name="stock_status" onchange="this.form.submit()"
<!-- 2. Filtro de Categoría (Tipo) -->
<div class="w-full md:w-1/4">
<select name="type" onchange="this.form.submit()"
class="block w-full p-3 text-sm text-black dark:text-white border border-neutral-300 dark:border-neutral-700 rounded-lg bg-neutral-200 dark:bg-neutral-800 focus:ring-neon-lime focus:border-neon-lime cursor-pointer">
<option value="">Todos</option>
<option value="low" {{ request('stock_status') == 'low' ? 'selected' : '' }} class="text-red-600 dark:text-red-300">Stock en Alerta</option>
<option value="medium" {{ request('stock_status') == 'medium' ? 'selected' : '' }} class="text-yellow-600 dark:text-yellow-300">Stock Bajo</option>
<option value="ok" {{ request('stock_status') == 'ok' ? 'selected' : '' }} class="text-green-600 dark:text-green-300">Stock Normal</option>
<option value="">Todas las Categorías</option>
<option value="bike" {{ request('type') == 'bike' ? 'selected' : '' }}>Bicicletas</option>
<option value="clothing" {{ request('type') == 'clothing' ? 'selected' : '' }}>Indumentaria</option>
<option value="accessory" {{ request('type') == 'accessory' ? 'selected' : '' }}>Accesorios</option>
<option value="spare" {{ request('type') == 'spare' ? 'selected' : '' }}>Repuestos</option>
<option value="children" {{ request('type') == 'children' ? 'selected' : '' }}>Infantil</option>
<option value="rollers" {{ request('type') == 'rollers' ? 'selected' : '' }}>Rollers</option>
<option value="skate" {{ request('type') == 'skate' ? 'selected' : '' }}>Skate</option>
<option value="other" {{ request('type') == 'other' ? 'selected' : '' }}>Otros</option>
<option value="service" {{ request('type') == 'service' ? 'selected' : '' }}>Servicios</option>
</select>
</div>
<!-- 3. Filtro de Estado de Stock -->
<div class="w-full md:w-1/4">
<select name="stock_status" onchange="this.form.submit()"
class="block w-full p-3 text-sm text-black dark:text-white border border-neutral-300 dark:border-neutral-700 rounded-lg bg-neutral-200 dark:bg-neutral-800 focus:ring-neon-lime focus:border-neon-lime cursor-pointer">
<option value="">Cualquier Stock</option>
<option value="low" {{ request('stock_status') == 'low' ? 'selected' : '' }} class="text-red-600 dark:text-red-300 font-semibold">Stock en Alerta</option>
<option value="medium" {{ request('stock_status') == 'medium' ? 'selected' : '' }} class="text-yellow-600 dark:text-yellow-300 font-semibold">Stock Bajo</option>
<option value="ok" {{ request('stock_status') == 'ok' ? 'selected' : '' }} class="text-green-600 dark:text-green-300 font-semibold">Stock Normal</option>
</select>
</div>
<!-- Botón Limpiar Filtros -->
@if(request('search') || request('type') || request('stock_status'))
<div class="w-full md:w-auto flex">
<a href="{{ route('productos.index') }}" title="Limpiar Filtros"
class="flex items-center justify-center p-3 text-sm font-bold text-red-600 dark:text-red-400 bg-red-100 dark:bg-red-900/30 rounded-lg hover:bg-red-200 dark:hover:bg-red-900/50 border border-red-200 dark:border-red-800 transition-colors">
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18 17.94 6M18 18 6.06 6"/>
</svg>
</a>
</div>
@endif
</form>
<!-- Botón Nuevo -->
<a href="{{ route('productos.create') }}" class="w-full md:w-auto text-center px-5 py-3 text-sm font-bold text-neon-lime dark:text-neutral-900 bg-neutral-950 dark:bg-neon-lime rounded-lg hover:bg-neutral-900/80 hover:dark:bg-[#b3e600] transition-colors uppercase tracking-wide">
<a href="{{ route('productos.create') }}" class="w-full xl:w-auto text-center px-5 py-3 text-sm font-bold text-neon-lime dark:text-neutral-900 bg-neutral-950 dark:bg-neon-lime rounded-lg hover:bg-neutral-900/80 hover:dark:bg-[#b3e600] transition-colors uppercase tracking-wide">
+ Nuevo Producto
</a>
</div>
<!-- Tabla de Productos -->
<div class="relative overflow-x-auto shadow-md sm:rounded-lg border border-gray-400 dark:border-neutral-800 w-full">
<table class="w-full text-sm text-left rtl:text-right text-neutral-900 dark:text-white">
<thead class="text-xs text-neutral-800 dark:text-gray-300 uppercase bg-gray-400 dark:bg-neutral-800 border-b border-gray-300 dark:border-neutral-700">
<tr>
<th scope="col" class="px-6 py-3">Producto / SKU</th>
<th scope="col" class="px-6 py-3">Producto</th>
<th scope="col" class="px-6 py-3">Tipo</th>
<th scope="col" class="px-6 py-3">Precio</th>
<th scope="col" class="px-6 py-3 text-center">Stock</th>
@@ -54,13 +87,16 @@
<tr class="bg-gray-200/50 dark:bg-neutral-900/50 border-b border-gray-400 dark:border-neutral-800 hover:bg-gray-400 hover:dark:bg-neutral-800 transition-colors group">
<td class="px-6 py-4 font-medium whitespace-nowrap">
<div class="text-base font-bold">{{ $product->name }}</div>
<div class="text-xs text-gray-600 dark:text-gray-400 font-mono">{{ $product->sku }}</div>
<div class="text-xs text-gray-600 dark:text-gray-400 font-mono">{{ $product->sku ?? 'Sin SKU' }}</div>
</td>
<td class="px-6 py-4">
@if($product->type === 'bike') <x-ui.badge color="neon">Bicicleta</x-ui.badge>
@elseif($product->type === 'clothing') <x-ui.badge color="blue">Indumentaria</x-ui.badge>
@elseif($product->type === 'spare') <x-ui.badge color="gray">Repuesto</x-ui.badge>
@else <x-ui.badge color="yellow">Accesorio</x-ui.badge> @endif
@elseif($product->type === 'children') <x-ui.badge color="pink">Infantil</x-ui.badge>
@elseif($product->type === 'rollers') <x-ui.badge color="purple">Rollers</x-ui.badge>
@elseif($product->type === 'skate') <x-ui.badge color="orange">Skate</x-ui.badge>
@else <x-ui.badge color="yellow">Accesorio / Otro</x-ui.badge> @endif
</td>
<td class="px-6 py-4 font-mono">
${{ number_format($product->price, 2) }}
@@ -107,6 +143,7 @@
</tbody>
</table>
</div>
<!-- Paginación -->
<div class="mt-4 w-full">
{{ $products->links() }}