Skip to content

Commit df664b4

Browse files
committed
Ajuste de rutas
1 parent 9194b98 commit df664b4

5 files changed

Lines changed: 35 additions & 22 deletions

File tree

Frontend/app/Http/Controllers/Estadisticas/EstadisticasController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public function index()
2525
$productosMasVendidos = $this->productosMasVendidosService->obtenerProductosMasVendidos(10);
2626
$usuariosRegistrados = $this->usuariosRegistradosService->obtenerUsuariosRegistrados();
2727

28-
return view('estadisticas.index', compact('productosMasVendidos', 'usuariosRegistrados'));
28+
return view('Estadisticas.index', compact('productosMasVendidos', 'usuariosRegistrados'));
2929
}
3030
}

Frontend/app/Http/Controllers/Productos/Categoriaproductos.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
class Categoriaproductos extends Controller
1010
{
11-
private $apiBaseUrl = 'http://localhost:8080';
11+
private $apiBaseUrl;
12+
13+
public function __construct()
14+
{
15+
$this->apiBaseUrl = env('API_BASE_URL', 'http://localhost:8080');
16+
}
1217

1318
public function index()
1419
{

Frontend/app/Http/Controllers/Productos/Menuproductos.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99

1010
class Menuproductos extends Controller
1111
{
12-
private $apiBaseUrl = 'http://localhost:8080';
12+
private $apiBaseUrl;
13+
14+
public function __construct()
15+
{
16+
$this->apiBaseUrl = env('API_BASE_URL', 'http://localhost:8080');
17+
}
1318

1419
public function index()
1520
{
1621
try {
1722
$responseCategorias = Http::get($this->apiBaseUrl . '/categorias');
1823
$responseProductos = Http::get($this->apiBaseUrl . '/productos');
19-
24+
2025
$categorias = collect([]);
2126
$productos = collect([]);
2227

@@ -40,7 +45,6 @@ public function index()
4045
'DESCRIPCION_PRODUCTO' => $prod['Descripcion Producto:'] ?? 'Producto fresco y delicioso',
4146
'PRECIO_PRODUCTO' => $prod['Precio:'] ?? 0,
4247
'STOCK_ACTUAL' => $prod['Stock Minímo:'] ?? 0,
43-
// Si la API no devuelve imagen, usar el helper para obtenerla
4448
'imagen' => $imagenApi ?? ProductImageHelper::getImage($nombreProducto, $prod['Id Producto:'] ?? null, $categoria['nombreCategoriaProducto'] ?? null)
4549
];
4650
});
@@ -62,7 +66,6 @@ public function index()
6266
'DESCRIPCION_PRODUCTO' => $prod['Descripcion Producto:'] ?? 'Producto fresco y delicioso',
6367
'PRECIO_PRODUCTO' => $prod['Precio:'] ?? 0,
6468
'STOCK_ACTUAL' => $prod['Stock Minímo:'] ?? 0,
65-
// Si la API no devuelve imagen, usar el helper para obtenerla
6669
'imagen' => $imagenApi ?? ProductImageHelper::getImage($nombreProducto, $prod['Id Producto:'] ?? null)
6770
];
6871
});
@@ -78,4 +81,4 @@ public function index()
7881
]);
7982
}
8083
}
81-
}
84+
}

Frontend/app/Http/Controllers/Productos/ProductoController.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99

1010
class ProductoController extends Controller
1111
{
12-
protected $apiUrl = 'http://localhost:8080/productos';
12+
protected $apiUrl;
13+
14+
public function __construct()
15+
{
16+
$this->apiUrl = env('API_BASE_URL', 'http://localhost:8080') . '/productos';
17+
}
1318

1419
public function index()
1520
{
@@ -35,13 +40,13 @@ public function index()
3540
10 => 'Pasteles Pollo',
3641
];
3742

38-
return view('productos.index', compact('productos', 'categorias'));
43+
return view('Productos.index', compact('productos', 'categorias'));
3944

4045
} catch (\Exception $e) {
4146
Log::error('Excepción en ProductoController@index: ' . $e->getMessage());
4247
$productos = [];
4348
$categorias = [];
44-
return view('productos.index', compact('productos', 'categorias'))
49+
return view('Productos.index', compact('productos', 'categorias'))
4550
->withErrors('No se pudo conectar con el servicio de productos.');
4651
}
4752
}

Frontend/app/Services/Inventario/CategoriaIngredientesService.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class CategoriaIngredientesService
1111
public function __construct()
1212
{
1313
// Obtiene la URL base de la API desde el archivo .env
14-
$this->baseUrl = env('API_BASE_URL', 'http://44.195.189.38');
14+
$this->baseUrl = env('API_BASE_URL', 'http://32.193.167.191');
1515
}
1616

1717
/**
@@ -28,7 +28,7 @@ protected function getApiClient()
2828
// =========================================================================
2929

3030
/**
31-
* Obtiene el listado de categorías de ingredientes desde la API.
31+
* Obtiene el listado de categorías de ingredientes desde la API.
3232
* @return array Retorna un array con 'success' y 'data' o 'error'.
3333
*/
3434
public function obtenerCategoriasIngredientes(): array
@@ -45,7 +45,7 @@ public function obtenerCategoriasIngredientes(): array
4545

4646
return [
4747
'success' => false,
48-
'error' => $response->json()['error'] ?? 'Error desconocido al obtener categorías (' . $response->status() . ')'
48+
'error' => $response->json()['error'] ?? 'Error desconocido al obtener categorías (' . $response->status() . ')'
4949
];
5050

5151
} catch (\Exception $e) {
@@ -61,7 +61,7 @@ public function obtenerCategoriasIngredientes(): array
6161
// =========================================================================
6262

6363
/**
64-
* Crea una nueva categoría de ingrediente.
64+
* Crea una nueva categoría de ingrediente.
6565
* @param array $data Array con nombreCategoria.
6666
*/
6767
public function crearCategoriaIngrediente(array $data): array
@@ -82,13 +82,13 @@ public function crearCategoriaIngrediente(array $data): array
8282

8383
return [
8484
'success' => false,
85-
'error' => $response->json()['error'] ?? 'Error al crear la categoría (' . $response->status() . ')'
85+
'error' => $response->json()['error'] ?? 'Error al crear la categoría (' . $response->status() . ')'
8686
];
8787

8888
} catch (\Exception $e) {
8989
return [
9090
'success' => false,
91-
'error' => 'Fallo de conexión al intentar crear: ' . $e->getMessage()
91+
'error' => 'Fallo de conexión al intentar crear: ' . $e->getMessage()
9292
];
9393
}
9494
}
@@ -98,7 +98,7 @@ public function crearCategoriaIngrediente(array $data): array
9898
// =========================================================================
9999

100100
/**
101-
* Actualiza una categoría de ingrediente existente por ID.
101+
* Actualiza una categoría de ingrediente existente por ID.
102102
*/
103103
public function actualizarCategoriaIngrediente(int $id, array $data): array
104104
{
@@ -118,13 +118,13 @@ public function actualizarCategoriaIngrediente(int $id, array $data): array
118118

119119
return [
120120
'success' => false,
121-
'error' => $response->json()['error'] ?? 'Error al actualizar la categoría (' . $response->status() . ')'
121+
'error' => $response->json()['error'] ?? 'Error al actualizar la categoría (' . $response->status() . ')'
122122
];
123123

124124
} catch (\Exception $e) {
125125
return [
126126
'success' => false,
127-
'error' => 'Fallo de conexión al intentar actualizar: ' . $e->getMessage()
127+
'error' => 'Fallo de conexión al intentar actualizar: ' . $e->getMessage()
128128
];
129129
}
130130
}
@@ -134,7 +134,7 @@ public function actualizarCategoriaIngrediente(int $id, array $data): array
134134
// =========================================================================
135135

136136
/**
137-
* Elimina una categoría de ingrediente por ID.
137+
* Elimina una categoría de ingrediente por ID.
138138
*/
139139
public function eliminarCategoriaIngrediente(int $id): array
140140
{
@@ -150,13 +150,13 @@ public function eliminarCategoriaIngrediente(int $id): array
150150

151151
return [
152152
'success' => false,
153-
'error' => $response->json()['error'] ?? 'Error al eliminar la categoría (' . $response->status() . ')'
153+
'error' => $response->json()['error'] ?? 'Error al eliminar la categoría (' . $response->status() . ')'
154154
];
155155

156156
} catch (\Exception $e) {
157157
return [
158158
'success' => false,
159-
'error' => 'Fallo de conexión al intentar eliminar: ' . $e->getMessage()
159+
'error' => 'Fallo de conexión al intentar eliminar: ' . $e->getMessage()
160160
];
161161
}
162162
}

0 commit comments

Comments
 (0)