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
  • - -
  • - +