11 changed files with 365 additions and 3 deletions
			
			
		@ -0,0 +1,23 @@ | 
				
			|||||
 | 
					yo | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Docentes | 
				
			||||
 | 
					Nombre | 
				
			||||
 | 
					materia que imparte | 
				
			||||
 | 
					no.tel | 
				
			||||
 | 
					correo | 
				
			||||
 | 
					tipo de licencia [es vigente la licencia o no] (opcional) | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Chofer | 
				
			||||
 | 
					Nombre | 
				
			||||
 | 
					no.tel | 
				
			||||
 | 
					correo | 
				
			||||
 | 
					tipo de licencia [es vigente la licencia o no] (opcional) | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Administradores | 
				
			||||
 | 
					Nombre | 
				
			||||
 | 
					no.tel | 
				
			||||
 | 
					correo | 
				
			||||
 | 
					
 | 
				
			||||
@ -0,0 +1,74 @@ | 
				
			|||||
 | 
					<?php | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					namespace App\Http\Controllers; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					use App\Models\Docentes; | 
				
			||||
 | 
					use Illuminate\Http\Request; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					class DocentesController extends Controller | 
				
			||||
 | 
					{ | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Display a listing of the resource. | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function index(Request $request) | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					        $docentes = Docentes::all(); | 
				
			||||
 | 
					        return view('docentes', ['docentes' => $docentes]); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Show the form for creating a new resource. | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function create() | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					        $docentes = Docentes::all(); | 
				
			||||
 | 
					        return view('docentesCrearEditar',['docentes'=>$docentes]); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Store a newly created resource in storage. | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function store(Request $request) | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					        $docente = new Docentes($request->all()); | 
				
			||||
 | 
					        $docente->save(); | 
				
			||||
 | 
					        return redirect()->route('docente.index')->with('success', 'Docente creado exitosamente.'); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Display the specified resource. | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function show(Docentes $docente) | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Show the form for editing the specified resource. | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function edit($id) | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					        $docente = Docentes::find($id); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Update the specified resource in storage. | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function update(Request $request, $id) | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					        $docente = Docentes::find($id); | 
				
			||||
 | 
					        $docente->fill($request->all()); | 
				
			||||
 | 
					        $docente->save(); | 
				
			||||
 | 
					        return redirect()->route('docente.index')->with('success', 'Docente actualizado correctamente'); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Remove the specified resource from storage. | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function destroy($id) | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					        $docente = Docentes::find($id); | 
				
			||||
 | 
					        $docente->delete(); | 
				
			||||
 | 
					        return redirect()->route('docente.index')->with('success', 'Docente eliminado correctamente'); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,19 @@ | 
				
			|||||
 | 
					<?php | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					namespace App\Models; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					use Illuminate\Database\Eloquent\Factories\HasFactory; | 
				
			||||
 | 
					use Illuminate\Database\Eloquent\Model; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					class Docentes extends Model | 
				
			||||
 | 
					{ | 
				
			||||
 | 
					    use HasFactory; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    protected $fillable = [ | 
				
			||||
 | 
					        'nombre', | 
				
			||||
 | 
					        'telefono', | 
				
			||||
 | 
					        'correo', | 
				
			||||
 | 
					        'tipo_licencia', | 
				
			||||
 | 
					        'materia' | 
				
			||||
 | 
					    ]; | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,27 @@ | 
				
			|||||
 | 
					<?php | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					namespace Database\Factories; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					use Illuminate\Database\Eloquent\Factories\Factory; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Docentes> | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					class DocentesFactory extends Factory | 
				
			||||
 | 
					{ | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Define the model's default state. | 
				
			||||
 | 
					     * | 
				
			||||
 | 
					     * @return array<string, mixed> | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function definition(): array | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					        return [ | 
				
			||||
 | 
					            'nombre' => $this->faker->name, | 
				
			||||
 | 
					            'telefono' => $this->faker->phoneNumber, | 
				
			||||
 | 
					            'correo' => $this->faker->email, | 
				
			||||
 | 
					            'tipo_licencia' => $this->faker->randomElement(['Vigente', 'No Vigente']), | 
				
			||||
 | 
					            'materia' => $this->faker->randomElement(['Matemáticas', 'Programación', 'Base de datos', 'Sistemas Operativos', 'Redes']), | 
				
			||||
 | 
					        ]; | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,32 @@ | 
				
			|||||
 | 
					<?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('docentes', function (Blueprint $table) { | 
				
			||||
 | 
					            $table->id(); | 
				
			||||
 | 
					            $table->string('nombre'); | 
				
			||||
 | 
					            $table->string('telefono'); | 
				
			||||
 | 
					            $table->string('correo'); | 
				
			||||
 | 
					            $table->string('tipo_licencia'); | 
				
			||||
 | 
					            $table->string('materia'); | 
				
			||||
 | 
					            $table->timestamps(); | 
				
			||||
 | 
					        }); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Reverse the migrations. | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function down(): void | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					        Schema::dropIfExists('docentes'); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					}; | 
				
			||||
@ -0,0 +1,17 @@ | 
				
			|||||
 | 
					<?php | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					namespace Database\Seeders; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					use Illuminate\Database\Console\Seeds\WithoutModelEvents; | 
				
			||||
 | 
					use Illuminate\Database\Seeder; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					class DocentesSeeder extends Seeder | 
				
			||||
 | 
					{ | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * Run the database seeds. | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public function run(): void | 
				
			||||
 | 
					    { | 
				
			||||
 | 
					        // | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,121 @@ | 
				
			|||||
 | 
					{{-- Start of Selection --}} | 
				
			||||
 | 
					@extends('layouts.dashboard') | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					@section('content') | 
				
			||||
 | 
					<div class="container mx-auto px-4 py-6"> | 
				
			||||
 | 
					    <!-- Encabezado --> | 
				
			||||
 | 
					    @if(session('success')) | 
				
			||||
 | 
					        <div 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"> | 
				
			||||
 | 
					        <div class="p-4 border-b border-gray-200 flex justify-between items-center"> | 
				
			||||
 | 
					            <h2 class="text-2xl font-bold">Gestión de Docentes</h2> | 
				
			||||
 | 
					            <a href="{{ route('docentes.create') }}" class="px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600"> | 
				
			||||
 | 
					                Crear Docente | 
				
			||||
 | 
					            </a> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        <!-- Barra de búsqueda --> | 
				
			||||
 | 
					        <div class="p-4 border-b border-gray-200 bg-gray-50"> | 
				
			||||
 | 
					            <form action="{{ route('docentes.index') }}" method="GET" class="flex gap-2"> | 
				
			||||
 | 
					                <div class="relative w-full sm:w-64"> | 
				
			||||
 | 
					                    <input type="text" | 
				
			||||
 | 
					                           name="busqueda" | 
				
			||||
 | 
					                           placeholder="Buscar docente..." | 
				
			||||
 | 
					                           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('docentes.index') }}" class="px-4 py-2 bg-gray-500 text-white rounded-lg hover:bg-gray-600"> | 
				
			||||
 | 
					                        Limpiar | 
				
			||||
 | 
					                    </a> | 
				
			||||
 | 
					                @endif | 
				
			||||
 | 
					            </form> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        <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</th> | 
				
			||||
 | 
					                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Teléfono</th> | 
				
			||||
 | 
					                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Correo</th> | 
				
			||||
 | 
					                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Tipo de Licencia</th> | 
				
			||||
 | 
					                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Materia</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"> | 
				
			||||
 | 
					                    @if($docentes->isEmpty()) | 
				
			||||
 | 
					                        <tr> | 
				
			||||
 | 
					                            <td colspan="7" class="px-6 py-4 text-center text-gray-500">No hay docentes registrados.</td> | 
				
			||||
 | 
					                        </tr> | 
				
			||||
 | 
					                    @else | 
				
			||||
 | 
					                        @foreach($docentes as $docente) | 
				
			||||
 | 
					                        <tr class="hover:bg-gray-50"> | 
				
			||||
 | 
					                            <td class="px-6 py-4 whitespace-nowrap">{{ $docente->id }}</td> | 
				
			||||
 | 
					                            <td class="px-6 py-4 whitespace-nowrap">{{ $docente->nombre }}</td> | 
				
			||||
 | 
					                            <td class="px-6 py-4 whitespace-nowrap">{{ $docente->telefono }}</td> | 
				
			||||
 | 
					                            <td class="px-6 py-4 whitespace-nowrap">{{ $docente->correo }}</td> | 
				
			||||
 | 
					                            <td class="px-6 py-4 whitespace-nowrap">{{ $docente->tipo_licencia }}</td> | 
				
			||||
 | 
					                            <td class="px-6 py-4 whitespace-nowrap">{{ $docente->materia }}</td> | 
				
			||||
 | 
					                            <td class="px-6 py-4 whitespace-nowrap"> | 
				
			||||
 | 
					                                <div class="flex gap-2"> | 
				
			||||
 | 
					                                    <a href="{{ route('docentes.edit', $docente->id) }}" class="text-blue-600 hover:text-blue-900"> | 
				
			||||
 | 
					                                        <i class="fas fa-edit"></i> <!-- Icono de edición --> | 
				
			||||
 | 
					                                    </a> | 
				
			||||
 | 
					                                    <form action="{{ route('docentes.destroy', $docente->id) }}" method="POST" class="inline" onsubmit="return false;"> | 
				
			||||
 | 
					                                        @csrf | 
				
			||||
 | 
					                                        @method('DELETE') | 
				
			||||
 | 
					                                        <button type="button" onclick="confirmarEliminacion(this)" class="text-red-600 hover:text-red-900"> | 
				
			||||
 | 
					                                            <i class="fas fa-trash"></i> <!-- Icono de eliminación --> | 
				
			||||
 | 
					                                        </button> | 
				
			||||
 | 
					                                    </form> | 
				
			||||
 | 
					                                </div> | 
				
			||||
 | 
					                            </td> | 
				
			||||
 | 
					                        </tr> | 
				
			||||
 | 
					                        @endforeach | 
				
			||||
 | 
					                    @endif | 
				
			||||
 | 
					                </tbody> | 
				
			||||
 | 
					            </table> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</div> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					<script> | 
				
			||||
 | 
					function confirmarEliminacion(button) { | 
				
			||||
 | 
					    Swal.fire({ | 
				
			||||
 | 
					        title: '¿Estás seguro?', | 
				
			||||
 | 
					        text: "Esta acción no se puede deshacer", | 
				
			||||
 | 
					        icon: 'warning', | 
				
			||||
 | 
					        showCancelButton: true, | 
				
			||||
 | 
					        confirmButtonColor: '#3085d6', | 
				
			||||
 | 
					        cancelButtonColor: '#d33', | 
				
			||||
 | 
					        confirmButtonText: 'Sí, eliminar', | 
				
			||||
 | 
					        cancelButtonText: 'Cancelar' | 
				
			||||
 | 
					    }).then((result) => { | 
				
			||||
 | 
					        if (result.isConfirmed) { | 
				
			||||
 | 
					            button.closest('form').onsubmit = null; | 
				
			||||
 | 
					            button.closest('form').submit(); | 
				
			||||
 | 
					        } | 
				
			||||
 | 
					    }); | 
				
			||||
 | 
					} | 
				
			||||
 | 
					</script> | 
				
			||||
 | 
					@endsection | 
				
			||||
 | 
					{{-- End of Selection --}} | 
				
			||||
@ -0,0 +1,46 @@ | 
				
			|||||
 | 
					@extends('layouts.dashboard') | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					@section('content') | 
				
			||||
 | 
					<div class="container mx-auto px-4 py-6"> | 
				
			||||
 | 
					    <div class="bg-white rounded-lg shadow-lg"> | 
				
			||||
 | 
					        <div class="p-4 border-b border-gray-200 flex justify-between items-center"> | 
				
			||||
 | 
					            <h2 class="text-2xl font-bold">{{ isset($docente) ? 'Editar Docente' : 'Crear Docente' }}</h2> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					        <div class="p-4"> | 
				
			||||
 | 
					            <form action="{{ isset($docente) ? route('docente.update', $docente->id) : route('docente.store') }}" method="POST"> | 
				
			||||
 | 
					                @csrf | 
				
			||||
 | 
					                @if(isset($docente)) | 
				
			||||
 | 
					                    @method('PUT') | 
				
			||||
 | 
					                @endif | 
				
			||||
 | 
					                <div class="grid grid-cols-1 gap-6"> | 
				
			||||
 | 
					                    <div> | 
				
			||||
 | 
					                        <label for="nombre" class="block text-sm font-medium text-gray-700">Nombre</label> | 
				
			||||
 | 
					                        <input type="text" name="nombre" id="nombre" value="{{ old('nombre', $docente->nombre ?? '') }}" class="mt-1 block w-full border border-gray-300 rounded-lg shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | 
				
			||||
 | 
					                    </div> | 
				
			||||
 | 
					                    <div> | 
				
			||||
 | 
					                        <label for="telefono" class="block text-sm font-medium text-gray-700">Teléfono</label> | 
				
			||||
 | 
					                        <input type="text" name="telefono" id="telefono" value="{{ old('telefono', $docente->telefono ?? '') }}" class="mt-1 block w-full border border-gray-300 rounded-lg shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | 
				
			||||
 | 
					                    </div> | 
				
			||||
 | 
					                    <div> | 
				
			||||
 | 
					                        <label for="correo" class="block text-sm font-medium text-gray-700">Correo</label> | 
				
			||||
 | 
					                        <input type="email" name="correo" id="correo" value="{{ old('correo', $docente->correo ?? '') }}" class="mt-1 block w-full border border-gray-300 rounded-lg shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | 
				
			||||
 | 
					                    </div> | 
				
			||||
 | 
					                    <div> | 
				
			||||
 | 
					                        <label for="tipo_licencia" class="block text-sm font-medium text-gray-700">Tipo de Licencia</label> | 
				
			||||
 | 
					                        <input type="text" name="tipo_licencia" id="tipo_licencia" value="{{ old('tipo_licencia', $docente->tipo_licencia ?? '') }}" class="mt-1 block w-full border border-gray-300 rounded-lg shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | 
				
			||||
 | 
					                    </div> | 
				
			||||
 | 
					                    <div> | 
				
			||||
 | 
					                        <label for="materia" class="block text-sm font-medium text-gray-700">Materia</label> | 
				
			||||
 | 
					                        <input type="text" name="materia" id="materia" value="{{ old('materia', $docente->materia ?? '') }}" class="mt-1 block w-full border border-gray-300 rounded-lg shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | 
				
			||||
 | 
					                    </div> | 
				
			||||
 | 
					                </div> | 
				
			||||
 | 
					                <div class="mt-6 flex justify-end"> | 
				
			||||
 | 
					                    <button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600"> | 
				
			||||
 | 
					                        {{ isset($docente) ? 'Actualizar' : 'Crear' }} | 
				
			||||
 | 
					                    </button> | 
				
			||||
 | 
					                </div> | 
				
			||||
 | 
					            </form> | 
				
			||||
 | 
					        </div> | 
				
			||||
 | 
					    </div> | 
				
			||||
 | 
					</div> | 
				
			||||
 | 
					@endsection | 
				
			||||
@ -1 +0,0 @@ | 
				
			|||||
yo | 
					 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue