From 61759009a97f7bebd3581e51eeb8771f98df76ac Mon Sep 17 00:00:00 2001 From: TheSilva7 Date: Wed, 5 Mar 2025 12:32:56 -0600 Subject: [PATCH] Docentes Creacion de la tabla docentes (tiene detalles) --- anotaciones | 23 ++++ app/Http/Controllers/DocentesController.php | 74 +++++++++++ app/Models/Docentes.php | 19 +++ database/factories/DocentesFactory.php | 27 ++++ ...025_03_05_172529_create_docentes_table.php | 32 +++++ database/seeders/DocentesSeeder.php | 17 +++ resources/views/docentes.blade.php | 121 ++++++++++++++++++ resources/views/docentesCrearEditar.blade.php | 46 +++++++ resources/views/layouts/dashboard.blade.php | 3 +- routes/web.php | 5 +- si | 1 - 11 files changed, 365 insertions(+), 3 deletions(-) create mode 100644 anotaciones create mode 100644 app/Http/Controllers/DocentesController.php create mode 100644 app/Models/Docentes.php create mode 100644 database/factories/DocentesFactory.php create mode 100644 database/migrations/2025_03_05_172529_create_docentes_table.php create mode 100644 database/seeders/DocentesSeeder.php create mode 100644 resources/views/docentes.blade.php create mode 100644 resources/views/docentesCrearEditar.blade.php delete mode 100644 si diff --git a/anotaciones b/anotaciones new file mode 100644 index 0000000..c0f1886 --- /dev/null +++ b/anotaciones @@ -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 + diff --git a/app/Http/Controllers/DocentesController.php b/app/Http/Controllers/DocentesController.php new file mode 100644 index 0000000..ede6174 --- /dev/null +++ b/app/Http/Controllers/DocentesController.php @@ -0,0 +1,74 @@ + $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'); + } +} diff --git a/app/Models/Docentes.php b/app/Models/Docentes.php new file mode 100644 index 0000000..8bd5954 --- /dev/null +++ b/app/Models/Docentes.php @@ -0,0 +1,19 @@ + + */ +class DocentesFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + 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']), + ]; + } +} diff --git a/database/migrations/2025_03_05_172529_create_docentes_table.php b/database/migrations/2025_03_05_172529_create_docentes_table.php new file mode 100644 index 0000000..aa78bd6 --- /dev/null +++ b/database/migrations/2025_03_05_172529_create_docentes_table.php @@ -0,0 +1,32 @@ +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'); + } +}; diff --git a/database/seeders/DocentesSeeder.php b/database/seeders/DocentesSeeder.php new file mode 100644 index 0000000..06cbb1c --- /dev/null +++ b/database/seeders/DocentesSeeder.php @@ -0,0 +1,17 @@ + + + @if(session('success')) + + @endif + + @if(session('error')) + + @endif + +
+
+

Gestión de Docentes

+ + Crear Docente + +
+ + +
+
+
+ +
+ +
+
+ + @if(request('busqueda')) + + Limpiar + + @endif +
+
+ +
+ + + + + + + + + + + + + + @if($docentes->isEmpty()) + + + + @else + @foreach($docentes as $docente) + + + + + + + + + + @endforeach + @endif + +
IDNombreTeléfonoCorreoTipo de LicenciaMateriaAcciones
No hay docentes registrados.
{{ $docente->id }}{{ $docente->nombre }}{{ $docente->telefono }}{{ $docente->correo }}{{ $docente->tipo_licencia }}{{ $docente->materia }} +
+ + + +
+ @csrf + @method('DELETE') + +
+
+
+
+
+ + + +@endsection +{{-- End of Selection --}} diff --git a/resources/views/docentesCrearEditar.blade.php b/resources/views/docentesCrearEditar.blade.php new file mode 100644 index 0000000..9cab84d --- /dev/null +++ b/resources/views/docentesCrearEditar.blade.php @@ -0,0 +1,46 @@ +@extends('layouts.dashboard') + +@section('content') +
+
+
+

{{ isset($docente) ? 'Editar Docente' : 'Crear Docente' }}

+
+
+
+ @csrf + @if(isset($docente)) + @method('PUT') + @endif +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+
+@endsection diff --git a/resources/views/layouts/dashboard.blade.php b/resources/views/layouts/dashboard.blade.php index 2f09da5..6482c65 100644 --- a/resources/views/layouts/dashboard.blade.php +++ b/resources/views/layouts/dashboard.blade.php @@ -69,6 +69,7 @@ class="pl-4 mt-2 space-y-1 text-sm"> +
  • @@ -116,7 +117,7 @@
    • - + Docentes diff --git a/routes/web.php b/routes/web.php index 96f55b6..2951b3d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\usuariosController; use App\Http\Controllers\HomeController; use App\Http\Controllers\MarcaController; +use App\Http\Controllers\DocentesController; /* |-------------------------------------------------------------------------- | Web Routes @@ -22,7 +23,7 @@ Route::get('/', function () { Auth::routes(['register'=>true,'reset'=>false]); Route::resource('marca', MarcaController::class); - +Route::resource('docentes', DocentesController::class); // Rutas protegidas que requieren autenticación Route::middleware(['auth'])->group(function () { @@ -34,4 +35,6 @@ Route::middleware(['auth'])->group(function () { Route::put('/usuarios/{id}', [usuariosController::class, 'update'])->name('usuarios.update'); Route::delete('/usuarios/{id}', [usuariosController::class, 'destroy'])->name('usuarios.destroy'); Route::get('/home', [HomeController::class, 'index'])->name('home'); + + }); diff --git a/si b/si deleted file mode 100644 index 092bfb9..0000000 --- a/si +++ /dev/null @@ -1 +0,0 @@ -yo