7 changed files with 472 additions and 20 deletions
@ -0,0 +1,28 @@ |
|||
<?php |
|||
|
|||
use Illuminate\Database\Migrations\Migration; |
|||
use Illuminate\Database\Schema\Blueprint; |
|||
use Illuminate\Support\Facades\Schema; |
|||
|
|||
return new class extends Migration |
|||
{ |
|||
/** |
|||
* Run the migrations. |
|||
*/ |
|||
public function up(): void |
|||
{ |
|||
Schema::table('prestamos', function (Blueprint $table) { |
|||
$table->boolean('eliminado')->default(false); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Reverse the migrations. |
|||
*/ |
|||
public function down(): void |
|||
{ |
|||
Schema::table('prestamos', function (Blueprint $table) { |
|||
$table->dropColumn('eliminado'); |
|||
}); |
|||
} |
|||
}; |
@ -0,0 +1,130 @@ |
|||
@extends('layouts.dashboard') |
|||
|
|||
@section('content') |
|||
<div class="container mx-auto px-4 py-6"> |
|||
<!-- Mensajes de éxito y error --> |
|||
@if(session('success')) |
|||
<div id="success-message" class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4" role="alert"> |
|||
<span class="block sm:inline">{{ session('success') }}</span> |
|||
</div> |
|||
@endif |
|||
|
|||
@if(session('error')) |
|||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4" role="alert"> |
|||
<span class="block sm:inline">{{ session('error') }}</span> |
|||
</div> |
|||
@endif |
|||
|
|||
<div class="bg-white rounded-lg shadow-lg"> |
|||
<!-- Encabezado con título y botones de acción --> |
|||
<div class="p-4 border-b border-gray-200 flex justify-between items-center"> |
|||
<h2 class="text-2xl font-bold">Gestión de Préstamos</h2> |
|||
<div class="flex items-center space-x-6"> |
|||
<!-- Agregar nuevo préstamo --> |
|||
<a href="{{ route('prestamos.create') }}" |
|||
class="text-blue-500 hover:text-blue-600 transition-colors duration-200" |
|||
title="Agregar nuevo préstamo"> |
|||
<i class="fas fa-plus text-xl"></i> |
|||
</a> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- Barra de búsqueda --> |
|||
<div class="p-4 border-b border-gray-200 bg-gray-50"> |
|||
<form action="{{ route('prestamos.index') }}" method="GET" class="flex gap-2"> |
|||
<div class="relative w-full sm:w-64"> |
|||
<input type="text" |
|||
name="busqueda" |
|||
placeholder="Buscar préstamo..." |
|||
value="{{ request('busqueda') }}" |
|||
class="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> |
|||
<div class="absolute left-3 top-2.5 text-gray-400"> |
|||
<i class="fas fa-search"></i> |
|||
</div> |
|||
</div> |
|||
<button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600"> |
|||
Buscar |
|||
</button> |
|||
@if(request('busqueda')) |
|||
<a href="{{ route('prestamos.index') }}" class="px-4 py-2 bg-gray-500 text-white rounded-lg hover:bg-gray-600"> |
|||
Limpiar |
|||
</a> |
|||
@endif |
|||
</form> |
|||
</div> |
|||
|
|||
<!-- Tabla de préstamos --> |
|||
<div class="overflow-x-auto"> |
|||
<table class="min-w-full divide-y divide-gray-200"> |
|||
<thead class="bg-gray-50"> |
|||
<tr> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nombre Solicitante</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Destino</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha y Hora Salida</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fecha y Hora Llegada</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Motivo</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Domicilio</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Numero de personas</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Chofer</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Estado</th> |
|||
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Acciones</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody class="bg-white divide-y divide-gray-200"> |
|||
@foreach($prestamos as $prestamo) |
|||
<tr class="hover:bg-gray-50"> |
|||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $prestamo->id }}</td> |
|||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->nombre_solicitante }}</td> |
|||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->destino }}</td> |
|||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->fecha_hora_salida }}</td> |
|||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->fecha_hora_llegada }}</td> |
|||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->motivo }}</td> |
|||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->domicilio }}</td> |
|||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->numero_perosonas}}</td> |
|||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $prestamo->cofer }}</td> |
|||
|
|||
|
|||
|
|||
|
|||
<td class="flex space-x-2 px-6 py-4 whitespace-nowrap text-sm"> |
|||
<a href="{{ route('prestamos.edit', $prestamo->id) }}" |
|||
class="text-yellow-600 hover:text-yellow-700 transition-colors duration-200" |
|||
title="Editar préstamo"> |
|||
<i class="fas fa-edit"></i> |
|||
</a> |
|||
<form action="{{ route('prestamos.destroy', $prestamo->id) }}" method="POST" class="d-inline"> |
|||
@csrf |
|||
@method('DELETE') |
|||
<a href="#" onclick="event.preventDefault(); this.closest('form').submit();" |
|||
class="text-red-600 hover:text-red-700 transition-colors duration-200" |
|||
title="Eliminar préstamo"> |
|||
<i class="fas fa-trash"></i> |
|||
</a> |
|||
</form> |
|||
</td> |
|||
</tr> |
|||
@endforeach |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<script> |
|||
// Desaparecer el mensaje después de 3 segundos |
|||
setTimeout(function() { |
|||
var message = document.getElementById('success-message'); |
|||
if (message) { |
|||
message.style.transition = 'opacity 0.5s ease'; |
|||
message.style.opacity = '0'; |
|||
setTimeout(function() { |
|||
message.remove(); |
|||
}, 500); |
|||
} |
|||
}, 3000); |
|||
</script> |
|||
@endsection |
|||
|
|||
|
|||
|
@ -0,0 +1,189 @@ |
|||
@extends('layouts.dashboard') |
|||
|
|||
@section('content') |
|||
<div class="container mx-auto px-4 py-6"> |
|||
<div class="max-w-lg mx-auto"> |
|||
<div class="bg-white rounded-lg shadow-lg overflow-hidden"> |
|||
<div class="p-6"> |
|||
<!-- Encabezado del formulario --> |
|||
<div class="flex items-center justify-between mb-6"> |
|||
<h2 class="text-2xl font-bold text-gray-800"> |
|||
{{ isset($prestamo) ? 'Editar Préstamo' : 'Nuevo Préstamo' }} |
|||
</h2> |
|||
<div class="h-10 w-10 bg-blue-100 rounded-full flex items-center justify-center"> |
|||
<i class="fas fa-car text-blue-600"></i> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- Mensajes de error --> |
|||
@if($errors->any()) |
|||
<div class="mb-6 bg-red-50 border-l-4 border-red-500 p-4 rounded-r-lg"> |
|||
<div class="flex items-center"> |
|||
<i class="fas fa-exclamation-circle text-red-500 mr-3"></i> |
|||
<div class="text-red-700"> |
|||
<ul> |
|||
@foreach($errors->all() as $error) |
|||
<li>{{ $error }}</li> |
|||
@endforeach |
|||
</ul> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
@endif |
|||
|
|||
<!-- Formulario --> |
|||
<form id="prestamoForm" |
|||
action="{{ isset($prestamo) ? route('prestamos.update', $prestamo->id) : route('prestamos.store') }}" |
|||
method="POST"> |
|||
@csrf |
|||
@if(isset($prestamo)) |
|||
@method('PUT') |
|||
@endif |
|||
|
|||
<div class="space-y-6"> |
|||
<!-- Campo Nombre Solicitante --> |
|||
<div> |
|||
<label for="nombre_solicitante" class="block text-sm font-medium text-gray-700 mb-2"> |
|||
Nombre del Solicitante |
|||
</label> |
|||
<input type="text" |
|||
name="nombre_solicitante" |
|||
id="nombre_solicitante" |
|||
class="block w-full border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500" |
|||
required |
|||
placeholder="Ingresa el nombre del solicitante" |
|||
value="{{ isset($prestamo) ? $prestamo->nombre_solicitante : old('nombre_solicitante') }}"> |
|||
@error('nombre_solicitante') |
|||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> |
|||
@enderror |
|||
</div> |
|||
|
|||
<!-- Campo Destino --> |
|||
<div> |
|||
<label for="destino" class="block text-sm font-medium text-gray-700 mb-2"> |
|||
Destino |
|||
</label> |
|||
<input type="text" |
|||
name="destino" |
|||
id="destino" |
|||
class="block w-full border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500" |
|||
required |
|||
placeholder="Ingresa el destino" |
|||
value="{{ isset($prestamo) ? $prestamo->destino : old('destino') }}"> |
|||
@error('destino') |
|||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> |
|||
@enderror |
|||
</div> |
|||
|
|||
<!-- Campo Fecha y Hora de Salida --> |
|||
<div> |
|||
<label for="fecha_hora_salida" class="block text-sm font-medium text-gray-700 mb-2"> |
|||
Fecha y Hora de Salida |
|||
</label> |
|||
<input type="datetime-local" |
|||
name="fecha_hora_salida" |
|||
id="fecha_hora_salida" |
|||
class="block w-full border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500" |
|||
required |
|||
value="{{ isset($prestamo) ? $prestamo->fecha_hora_salida : old('fecha_hora_salida') }}"> |
|||
@error('fecha_hora_salida') |
|||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> |
|||
@enderror |
|||
</div> |
|||
|
|||
<!-- Campo Fecha y Hora de Llegada --> |
|||
<div> |
|||
<label for="fecha_hora_llegada" class="block text-sm font-medium text-gray-700 mb-2"> |
|||
Fecha y Hora de Llegada |
|||
</label> |
|||
<input type="datetime-local" |
|||
name="fecha_hora_llegada" |
|||
id="fecha_hora_llegada" |
|||
class="block w-full border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500" |
|||
required |
|||
value="{{ isset($prestamo) ? $prestamo->fecha_hora_llegada : old('fecha_hora_llegada') }}"> |
|||
@error('fecha_hora_llegada') |
|||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> |
|||
@enderror |
|||
</div> |
|||
|
|||
<!-- Campo Motivo --> |
|||
<div> |
|||
<label for="motivo" class="block text-sm font-medium text-gray-700 mb-2"> |
|||
Motivo |
|||
</label> |
|||
<textarea name="motivo" |
|||
id="motivo" |
|||
class="block w-full border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500" |
|||
required |
|||
placeholder="Ingresa el motivo">{{ isset($prestamo) ? $prestamo->motivo : old('motivo') }}</textarea> |
|||
@error('motivo') |
|||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> |
|||
@enderror |
|||
</div> |
|||
|
|||
<!-- Campo Domicilio --> |
|||
<div> |
|||
<label for="domicilio" class="block text-sm font-medium text-gray-700 mb-2"> |
|||
Domicilio |
|||
</label> |
|||
<input type="text" |
|||
name="domicilio" |
|||
id="domicilio" |
|||
class="block w-full border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500" |
|||
required |
|||
placeholder="Ingresa el domicilio" |
|||
value="{{ isset($prestamo) ? $prestamo->domicilio : old('domicilio') }}"> |
|||
@error('domicilio') |
|||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> |
|||
@enderror |
|||
</div> |
|||
|
|||
<!-- Campo Número de Personas --> |
|||
<div> |
|||
<label for="numero_personas" class="block text-sm font-medium text-gray-700 mb-2"> |
|||
Número de Personas |
|||
</label> |
|||
<input type="number" |
|||
name="numero_personas" |
|||
id="numero_personas" |
|||
class="block w-full border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500" |
|||
required |
|||
placeholder="Ingresa el número de personas" |
|||
value="{{ isset($prestamo) ? $prestamo->numero_personas : old('numero_personas') }}"> |
|||
@error('numero_personas') |
|||
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> |
|||
@enderror |
|||
</div> |
|||
|
|||
<!-- Campo Chofer --> |
|||
<div> |
|||
<label for="chofer" class="inline-flex items-center"> |
|||
<input type="checkbox" |
|||
name="chofer" |
|||
id="chofer" |
|||
class="rounded border-gray-300 text-blue-600 shadow-sm focus:ring-blue-500" |
|||
{{ isset($prestamo) && $prestamo->chofer ? 'checked' : '' }}> |
|||
<span class="ml-2 text-sm text-gray-700">¿Requiere chofer?</span> |
|||
</label> |
|||
</div> |
|||
|
|||
<!-- Botones de acción --> |
|||
<div class="flex justify-end space-x-2 pt-4 border-t border-gray-200"> |
|||
<a href="{{ route('prestamos.index') }}" |
|||
class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"> |
|||
Cancelar |
|||
</a> |
|||
<button type="submit" |
|||
class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"> |
|||
{{ isset($prestamo) ? 'Actualizar' : 'Guardar' }} |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
@endsection |
|||
|
Loading…
Reference in new issue