diff --git a/app/Http/Controllers/CatalogoController.php b/app/Http/Controllers/CatalogoController.php new file mode 100644 index 0000000..b7e5632 --- /dev/null +++ b/app/Http/Controllers/CatalogoController.php @@ -0,0 +1,16 @@ +delete(); return redirect(route('productos.index')); } + + public function vistaUsuario($id){ + $producto = Product::find($id); + return view('productos.vistaUsuario', compact('producto')); + } } diff --git a/resources/views/catalogo.blade.php b/resources/views/catalogo.blade.php index fa26743..3f718c4 100644 --- a/resources/views/catalogo.blade.php +++ b/resources/views/catalogo.blade.php @@ -1,6 +1,45 @@ - + +
+

CATÁLOGO

+ @if ($productos->count() > 0) +
+ @foreach ($productos as $prod) +
+ {{-- Imagen si existe --}} + @if (!empty($prod->imagen)) + {{ $prod->name }} + @else +
+ Sin imagen +
+ @endif + {{-- Nombre --}} +

{{ $prod->nombre }}

+ {{-- Descripción corta --}} + @if (!empty($prod->descripcion)) +

{{ $prod->descripcion }}

+ @endif - \ No newline at end of file + {{-- Precio --}} + @if (!empty($prod->precio)) +

${{ number_format($prod->precio, 2, ',', '.') }}

+ @endif + + {{-- Botón --}} + + Ver producto + + +
+ @endforeach +
+ @else +

No hay productos disponibles.

+ @endif +
+
diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 1b0b21e..13ecb27 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -1,6 +1,8 @@ - -

BIENVENIDO {{Auth::user()->name}}

-
+ +

BIENVENIDO {{ Auth::user()->name }}

+ Ir a catalogo + @csrf +
diff --git a/resources/views/productos/vistaUsuario.blade.php b/resources/views/productos/vistaUsuario.blade.php new file mode 100644 index 0000000..fbcbba2 --- /dev/null +++ b/resources/views/productos/vistaUsuario.blade.php @@ -0,0 +1,12 @@ + +
+ Volver a catalogo +

Titulo: {{ $producto->nombre }}

+

+ Categoria: {{ $producto->Categoria }} +

+

+ {{ $producto->content }} +

+
+
diff --git a/routes/web.php b/routes/web.php index a3006d2..be3d780 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ group(function () { Route::delete('/productos/{id}', [ProductosController::class,'destroy'])->name('productos.destroy'); }); -Route::vieq('catalogo','catalogo')->name('catalogo'); \ No newline at end of file +Route::get('/catalogo', [CatalogoController::class,'catalogo'])->name('catalogo'); +Route::get('/productos/{id}/vistaUsuario', [ProductosController::class,'vistaUsuario'])->name('productos.vistaUsuario'); \ No newline at end of file