diff --git a/ -i b/ -i
deleted file mode 100644
index e69de29..0000000
diff --git a/app/Http/Controllers/PrestamoController.php b/app/Http/Controllers/PrestamoController.php
index 01c4006..5490623 100644
--- a/app/Http/Controllers/PrestamoController.php
+++ b/app/Http/Controllers/PrestamoController.php
@@ -225,4 +225,35 @@ class PrestamoController extends Controller
return redirect()->back()->with('error', 'Formato no soportado');
}
}
+
+ public function show($id)
+ {
+ $prestamo = \App\Models\Prestamo::findOrFail($id);
+ return view('prestamos.show', compact('prestamo'));
+ }
+
+ public function pendientes()
+ {
+ $prestamos = \App\Models\Prestamo::where('estado', 'pendiente')->where('eliminado', 0)->get();
+ return view('prestamos.pendientes', compact('prestamos'));
+ }
+
+ public function rechazados(Request $request)
+ {
+ $busqueda = $request->busqueda;
+
+ $prestamos = \App\Models\Prestamo::where('estado', 'rechazado')
+ ->where('eliminado', 0)
+ ->when($busqueda, function($query) use ($busqueda) {
+ $query->where(function($q) use ($busqueda) {
+ $q->where('nombre_solicitante', 'LIKE', "%{$busqueda}%")
+ ->orWhere('destino', 'LIKE', "%{$busqueda}%")
+ ->orWhere('motivo', 'LIKE', "%{$busqueda}%");
+ });
+ })
+ ->orderBy('created_at', 'desc')
+ ->get();
+
+ return view('prestamos.rechazados', compact('prestamos'));
+ }
}
diff --git a/database/migrations/2025_04_01_191325_add_estado_to_prestamos_table.php b/database/migrations/2025_04_01_191325_add_estado_to_prestamos_table.php
index c47e8b3..c5d3a01 100644
--- a/database/migrations/2025_04_01_191325_add_estado_to_prestamos_table.php
+++ b/database/migrations/2025_04_01_191325_add_estado_to_prestamos_table.php
@@ -12,7 +12,8 @@ return new class extends Migration
public function up(): void
{
Schema::table('prestamos', function (Blueprint $table) {
- $table->enum('estado', ['pendiente', 'aceptado', 'rechazado'])->default('pendiente')->after('chofer');
+ // $table->enum('estado', ['pendiente', 'aceptado', 'rechazado'])->default('pendiente')->after('chofer');
+ // Línea comentada porque la columna ya existe
});
}
diff --git a/database/migrations/2025_04_01_192918_add_fecha_aceptacion_to_prestamos_table.php b/database/migrations/2025_04_01_192918_add_fecha_aceptacion_to_prestamos_table.php
index af9986e..e671bde 100644
--- a/database/migrations/2025_04_01_192918_add_fecha_aceptacion_to_prestamos_table.php
+++ b/database/migrations/2025_04_01_192918_add_fecha_aceptacion_to_prestamos_table.php
@@ -12,7 +12,7 @@ return new class extends Migration
public function up(): void
{
Schema::table('prestamos', function (Blueprint $table) {
- //
+ $table->timestamp('fecha_aceptacion')->nullable();
});
}
@@ -22,7 +22,7 @@ return new class extends Migration
public function down(): void
{
Schema::table('prestamos', function (Blueprint $table) {
- //
+ $table->dropColumn('fecha_aceptacion');
});
}
};
diff --git a/database/migrations/2025_05_08_175205_add_estado_to_prestamos_table.php b/database/migrations/2025_05_08_175205_add_estado_to_prestamos_table.php
new file mode 100644
index 0000000..c47e8b3
--- /dev/null
+++ b/database/migrations/2025_05_08_175205_add_estado_to_prestamos_table.php
@@ -0,0 +1,28 @@
+enum('estado', ['pendiente', 'aceptado', 'rechazado'])->default('pendiente')->after('chofer');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('prestamos', function (Blueprint $table) {
+ $table->dropColumn('estado');
+ });
+ }
+};
diff --git a/database/migrations/[timestamp]_add_fecha_aceptacion_to_prestamos_table.php b/database/migrations/[timestamp]_add_fecha_aceptacion_to_prestamos_table.php
deleted file mode 100644
index b67a566..0000000
--- a/database/migrations/[timestamp]_add_fecha_aceptacion_to_prestamos_table.php
+++ /dev/null
@@ -1,20 +0,0 @@
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class AddFechaAceptacionToPrestamosTable extends Migration
-{
- public function up()
- {
- Schema::table('prestamos', function (Blueprint $table) {
- $table->timestamp('fecha_aceptacion')->nullable()->after('estado');
- });
- }
-
- public function down()
- {
- Schema::table('prestamos', function (Blueprint $table) {
- $table->dropColumn('fecha_aceptacion');
- });
- }
-}
\ No newline at end of file
diff --git a/resources/views/layouts/dashboard.blade.php b/resources/views/layouts/dashboard.blade.php
index c9c4ead..36a44bc 100644
--- a/resources/views/layouts/dashboard.blade.php
+++ b/resources/views/layouts/dashboard.blade.php
@@ -78,24 +78,26 @@
Nuevo Préstamo
-
+
-
-
- Préstamos Rechazados
+
+
+ Préstamos pendientes/aceptados
-
-
- Préstamos Aceptados
+
+
+ Préstamos Rechazados
+
@@ -181,17 +183,7 @@
Tipo de Gasolina
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+ {{ strtoupper(substr(Auth::user()->name ?? 'U', 0, 1)) }}{{ strtoupper(substr(Auth::user()->name ?? 'U', 1, 1)) }}
+
{{ Auth::user()->name ?? 'Usuario' }}
+
diff --git a/resources/views/prestamos/pendientes.blade.php b/resources/views/prestamos/pendientes.blade.php
new file mode 100644
index 0000000..176f0d1
--- /dev/null
+++ b/resources/views/prestamos/pendientes.blade.php
@@ -0,0 +1,47 @@
+@extends('layouts.dashboard')
+
+@section('content')
+
+
+
+
Préstamos Pendientes
+
+
+
+
+
+ # |
+ Solicitante |
+ Destino |
+ Fecha Salida |
+ Fecha Llegada |
+ Motivo |
+ Domicilio |
+ Personas |
+ Chofer |
+
+
+
+ @forelse($prestamos as $index => $prestamo)
+
+ {{ $index + 1 }} |
+ {{ $prestamo->nombre_solicitante }} |
+ {{ $prestamo->destino }} |
+ {{ $prestamo->fecha_hora_salida }} |
+ {{ $prestamo->fecha_hora_llegada }} |
+ {{ $prestamo->motivo }} |
+ {{ $prestamo->domicilio }} |
+ {{ $prestamo->numero_personas }} |
+ {{ $prestamo->chofer ? 'Sí' : 'No' }} |
+
+ @empty
+
+ No hay préstamos pendientes. |
+
+ @endforelse
+
+
+
+
+
+@endsection
diff --git a/resources/views/prestamos/rechazados.blade.php b/resources/views/prestamos/rechazados.blade.php
new file mode 100644
index 0000000..9e3eb24
--- /dev/null
+++ b/resources/views/prestamos/rechazados.blade.php
@@ -0,0 +1,91 @@
+@extends('layouts.dashboard')
+
+@section('content')
+
+
+
+
Préstamos Rechazados
+
+
+
+
+
+
+
+ Número |
+ Solicitante |
+ Destino |
+ Fecha Salida |
+ Fecha Llegada |
+ Motivo |
+ Domicilio |
+ Personas |
+ Chofer |
+ Estado |
+
+
+
+ @forelse($prestamos as $prestamo)
+
+ {{ $prestamo->id }} |
+
+
+ {{ $prestamo->nombre_solicitante }}
+ |
+
+
+ {{ $prestamo->destino }}
+ |
+
+
+ {{ \Carbon\Carbon::parse($prestamo->fecha_hora_salida)->format('d/m/Y H:i') }}
+ |
+
+
+ {{ \Carbon\Carbon::parse($prestamo->fecha_hora_llegada)->format('d/m/Y H:i') }}
+ |
+ {{ $prestamo->motivo }} |
+ {{ $prestamo->domicilio }} |
+ {{ $prestamo->numero_personas }} |
+ {{ $prestamo->chofer ? 'Sí' : 'No' }} |
+
+
+
+
+
+ Rechazado
+
+ |
+
+ @empty
+
+ No hay préstamos rechazados. |
+
+ @endforelse
+
+
+
+
+
+@endsection
diff --git a/resources/views/prestamos/show.blade.php b/resources/views/prestamos/show.blade.php
new file mode 100644
index 0000000..5b725f6
--- /dev/null
+++ b/resources/views/prestamos/show.blade.php
@@ -0,0 +1,23 @@
+@extends('layouts.dashboard')
+
+@section('content')
+
+
+
Detalle del Préstamo
+
+ - Solicitante: {{ $prestamo->nombre_solicitante }}
+ - Destino: {{ $prestamo->destino }}
+ - Fecha y Hora de Salida: {{ $prestamo->fecha_hora_salida }}
+ - Fecha y Hora de Llegada: {{ $prestamo->fecha_hora_llegada }}
+ - Motivo: {{ $prestamo->motivo }}
+ - Domicilio: {{ $prestamo->domicilio }}
+ - Número de Personas: {{ $prestamo->numero_personas }}
+ - Chofer: {{ $prestamo->chofer ? 'Sí' : 'No' }}
+ - Estado: {{ $prestamo->estado }}
+
+
+
+
+@endsection
diff --git a/routes/web.php b/routes/web.php
index c18966c..dbffc48 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -63,6 +63,8 @@ use App\Http\Controllers\DespartamentoController;
Route::post('/prestamos/{id}/aceptar', [PrestamoController::class, 'aceptar'])->name('prestamos.aceptar');
Route::post('/prestamos/{id}/rechazar', [PrestamoController::class, 'rechazar'])->name('prestamos.rechazar');
Route::get('/prestamos/historial', [PrestamoController::class, 'historial'])->name('prestamos.historial');
+ Route::get('/prestamos/pendientes', [PrestamoController::class, 'pendientes'])->name('prestamos.pendientes');
+ Route::get('/prestamos/rechazados', [PrestamoController::class, 'rechazados'])->name('prestamos.rechazados');
// Después la ruta de recurso (más general)
Route::resource('prestamos', PrestamoController::class);
@@ -73,6 +75,7 @@ use App\Http\Controllers\DespartamentoController;
// Rutas protegidas que requieren autenticación
+
// Rutas protegidas que requieren autenticación
Route::middleware(['auth'])->group(function () {