Browse Source
Ya estan funcionales, solo hace falta hacerle unos ajustes para que esten al 100%main
24 changed files with 698 additions and 86 deletions
@ -0,0 +1,24 @@ |
|||
<?php |
|||
|
|||
namespace App\Exports; |
|||
|
|||
use App\Models\User; |
|||
use Maatwebsite\Excel\Concerns\FromCollection; |
|||
use Maatwebsite\Excel\Concerns\WithHeadings; |
|||
|
|||
class UsuariosExport implements FromCollection, WithHeadings |
|||
{ |
|||
public function collection() |
|||
{ |
|||
return User::select('id', 'name', 'email')->get(); |
|||
} |
|||
|
|||
public function headings(): array |
|||
{ |
|||
return [ |
|||
'ID', |
|||
'Nombre', |
|||
'Email' |
|||
]; |
|||
} |
|||
} |
@ -0,0 +1,65 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers; |
|||
|
|||
use App\Models\prestamo; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class PrestamoController extends Controller |
|||
{ |
|||
/** |
|||
* Display a listing of the resource. |
|||
*/ |
|||
public function index() |
|||
{ |
|||
// |
|||
} |
|||
|
|||
/** |
|||
* Show the form for creating a new resource. |
|||
*/ |
|||
public function create() |
|||
{ |
|||
// |
|||
} |
|||
|
|||
/** |
|||
* Store a newly created resource in storage. |
|||
*/ |
|||
public function store(Request $request) |
|||
{ |
|||
// |
|||
} |
|||
|
|||
/** |
|||
* Display the specified resource. |
|||
*/ |
|||
public function show(prestamo $prestamo) |
|||
{ |
|||
// |
|||
} |
|||
|
|||
/** |
|||
* Show the form for editing the specified resource. |
|||
*/ |
|||
public function edit(prestamo $prestamo) |
|||
{ |
|||
// |
|||
} |
|||
|
|||
/** |
|||
* Update the specified resource in storage. |
|||
*/ |
|||
public function update(Request $request, prestamo $prestamo) |
|||
{ |
|||
// |
|||
} |
|||
|
|||
/** |
|||
* Remove the specified resource from storage. |
|||
*/ |
|||
public function destroy(prestamo $prestamo) |
|||
{ |
|||
// |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class prestamo extends Model |
|||
{ |
|||
use HasFactory; |
|||
} |
@ -0,0 +1,23 @@ |
|||
<?php |
|||
|
|||
namespace Database\Factories; |
|||
|
|||
use Illuminate\Database\Eloquent\Factories\Factory; |
|||
|
|||
/** |
|||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\prestamo> |
|||
*/ |
|||
class PrestamoFactory extends Factory |
|||
{ |
|||
/** |
|||
* Define the model's default state. |
|||
* |
|||
* @return array<string, mixed> |
|||
*/ |
|||
public function definition(): array |
|||
{ |
|||
return [ |
|||
// |
|||
]; |
|||
} |
|||
} |
@ -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('users', function (Blueprint $table) { |
|||
$table->boolean('eliminado')->default(false); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Reverse the migrations. |
|||
*/ |
|||
public function down(): void |
|||
{ |
|||
Schema::table('users', function (Blueprint $table) { |
|||
$table->dropColumn('eliminado'); |
|||
}); |
|||
} |
|||
}; |
@ -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('tipos_veiculos', function (Blueprint $table) { |
|||
$table->boolean('status')->default(true); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Reverse the migrations. |
|||
*/ |
|||
public function down(): void |
|||
{ |
|||
Schema::table('tipos_veiculos', function (Blueprint $table) { |
|||
$table->dropColumn('status'); |
|||
}); |
|||
} |
|||
}; |
@ -0,0 +1,27 @@ |
|||
<?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::create('prestamos', function (Blueprint $table) { |
|||
$table->id(); |
|||
$table->timestamps(); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Reverse the migrations. |
|||
*/ |
|||
public function down(): void |
|||
{ |
|||
Schema::dropIfExists('prestamos'); |
|||
} |
|||
}; |
@ -0,0 +1,48 @@ |
|||
<!-- resources/views/exports/usuarios-pdf.blade.php --> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<title>Lista de Usuarios</title> |
|||
<style> |
|||
/* Estilos opcionales para el PDF */ |
|||
table { |
|||
width: 100%; |
|||
border-collapse: collapse; |
|||
} |
|||
th, td { |
|||
border: 1px solid black; |
|||
padding: 8px; |
|||
text-align: left; |
|||
} |
|||
</style> |
|||
</head> |
|||
<body> |
|||
<h1>Lista de Usuarios</h1> |
|||
<table> |
|||
<thead> |
|||
<tr> |
|||
<th>ID</th> |
|||
<th>Nombre</th> |
|||
<th>Email</th> |
|||
<th>Apellido</th> |
|||
<th>Puesto</th> |
|||
<th>Carrera</th> |
|||
<th>Teléfono</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
@foreach($usuarios as $usuario) |
|||
<tr> |
|||
<td>{{ $usuario->id }}</td> |
|||
<td>{{ $usuario->name }}</td> |
|||
<td>{{ $usuario->email }}</td> |
|||
<td>{{ $usuario->apellido }}</td> |
|||
<td>{{ $usuario->puesto }}</td> |
|||
<td>{{ $usuario->carrera }}</td> |
|||
<td>{{ $usuario->telefono }}</td> |
|||
</tr> |
|||
@endforeach |
|||
</tbody> |
|||
</table> |
|||
</body> |
|||
</html> |
@ -0,0 +1,87 @@ |
|||
@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"> |
|||
<div class="flex items-center justify-between mb-6"> |
|||
<h2 class="text-2xl font-bold text-gray-800"> |
|||
{{ isset($usuario) ? 'Editar Usuario' : 'Nuevo Usuario' }} |
|||
</h2> |
|||
</div> |
|||
|
|||
@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"> |
|||
<div class="text-red-700"> |
|||
<ul> |
|||
@foreach($errors->all() as $error) |
|||
<li>{{ $error }}</li> |
|||
@endforeach |
|||
</ul> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
@endif |
|||
|
|||
<form action="{{ isset($usuario) ? route('usuarios.update', $usuario->id) : route('usuarios.store') }}" method="POST"> |
|||
@csrf |
|||
@if(isset($usuario)) |
|||
@method('PUT') |
|||
@endif |
|||
|
|||
<div class="space-y-6"> |
|||
<div> |
|||
<label for="name" class="block text-sm font-medium text-gray-700 mb-2">Nombre</label> |
|||
<input type="text" name="name" id="name" class="block w-full px-3 py-2 border border-gray-300 rounded-md" required value="{{ isset($usuario) ? $usuario->name : old('name') }}"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">Correo Electrónico</label> |
|||
<input type="email" name="email" id="email" class="block w-full px-3 py-2 border border-gray-300 rounded-md" required value="{{ isset($usuario) ? $usuario->email : old('email') }}"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="apellido" class="block text-sm font-medium text-gray-700 mb-2">Apellido</label> |
|||
<input type="text" name="apellido" id="apellido" class="block w-full px-3 py-2 border border-gray-300 rounded-md" required value="{{ isset($usuario) ? $usuario->apellido : old('apellido') }}"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="puesto" class="block text-sm font-medium text-gray-700 mb-2">Puesto</label> |
|||
<input type="text" name="puesto" id="puesto" class="block w-full px-3 py-2 border border-gray-300 rounded-md" required value="{{ isset($usuario) ? $usuario->puesto : old('puesto') }}"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="carrera" class="block text-sm font-medium text-gray-700 mb-2">Carrera</label> |
|||
<input type="text" name="carrera" id="carrera" class="block w-full px-3 py-2 border border-gray-300 rounded-md" required value="{{ isset($usuario) ? $usuario->carrera : old('carrera') }}"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="telefono" class="block text-sm font-medium text-gray-700 mb-2">Teléfono</label> |
|||
<input type="text" name="telefono" id="telefono" class="block w-full px-3 py-2 border border-gray-300 rounded-md" required value="{{ isset($usuario) ? $usuario->telefono : old('telefono') }}"> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">Contraseña</label> |
|||
<input type="password" name="password" id="password" class="block w-full px-3 py-2 border border-gray-300 rounded-md" {{ isset($usuario) ? '' : 'required' }}> |
|||
</div> |
|||
|
|||
<div> |
|||
<label for="password_confirmation" class="block text-sm font-medium text-gray-700 mb-2">Confirmar Contraseña</label> |
|||
<input type="password" name="password_confirmation" id="password_confirmation" class="block w-full px-3 py-2 border border-gray-300 rounded-md" {{ isset($usuario) ? '' : 'required' }}> |
|||
</div> |
|||
|
|||
<div class="flex justify-end space-x-2 pt-4 border-t border-gray-200"> |
|||
<a href="{{ route('usuarios') }}" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">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"> |
|||
{{ isset($usuario) ? 'Actualizar' : 'Guardar' }} |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
@endsection |
Loading…
Reference in new issue