From 01bb69269cd90b62a9c8dd7725744d2094c8d631 Mon Sep 17 00:00:00 2001 From: alekeyrivas Date: Wed, 19 Jun 2024 10:01:40 -0600 Subject: [PATCH 1/5] Se agrego archivos para catalago profesiones --- app/Http/Controllers/profesionController.php | 42 ++- app/Models/profesion.php | 15 +- ...4_06_03_183521_create_profesions_table.php | 2 +- .../2024_06_03_183943_create_cargos_table.php | 1 + ...03_184326_create_caracteristicas_table.php | 1 + ...24_06_03_194040_create_subgrupos_table.php | 1 + ..._194301_add_updated_at_to_cargos_table.php | 32 -- ...dd_timestamps_to_caracteristicas_table.php | 23 -- .../catalagos/caracteristicas.blade.php | 55 ++-- .../views/adminGen/catalagos/cargos.blade.php | 40 +-- .../views/adminGen/catalagos/grupos.blade.php | 49 ++- .../adminGen/catalagos/profesion.blade.php | 282 ++++++++++++++++++ routes/web.php | 16 +- 13 files changed, 419 insertions(+), 140 deletions(-) delete mode 100644 database/migrations/2024_06_10_194301_add_updated_at_to_cargos_table.php delete mode 100644 database/migrations/2024_06_12_202929_add_timestamps_to_caracteristicas_table.php create mode 100644 resources/views/adminGen/catalagos/profesion.blade.php diff --git a/app/Http/Controllers/profesionController.php b/app/Http/Controllers/profesionController.php index b4cacfe..7eb83d0 100644 --- a/app/Http/Controllers/profesionController.php +++ b/app/Http/Controllers/profesionController.php @@ -3,8 +3,46 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Models\Profesion; -class profesionController extends Controller +class ProfesionController extends Controller { - // + public function index() + { + $profesiones = Profesion::all(); + return view('catalogos.profesion.index', compact('profesiones')); + } + + public function store(Request $request) + { + $validated = $request->validate([ + 'nombre' => 'required|string|max:255', + 'abreviatura' => 'required|string|max:10', + ]); + + Profesion::create($validated); + + return redirect()->route('catalogos.profesion.get'); + } + + public function update(Request $request, $id) + { + $validated = $request->validate([ + 'nombre' => 'required|string|max:255', + 'abreviatura' => 'required|string|max:10', + ]); + + $profesion = Profesion::findOrFail($id); + $profesion->update($validated); + + return redirect()->route('catalogos.profesion.get'); + } + + public function destroy($id) + { + $profesion = Profesion::findOrFail($id); + $profesion->delete(); + + return redirect()->route('catalogos.profesion.get'); + } } diff --git a/app/Models/profesion.php b/app/Models/profesion.php index cfc60d4..25dcb14 100644 --- a/app/Models/profesion.php +++ b/app/Models/profesion.php @@ -4,8 +4,21 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; -class profesion extends Model +class Profesion extends Model { use HasFactory; + + protected $primaryKey = 'id'; + + protected $fillable = [ + 'nombre', + 'abreviatura', + ]; + + public function users(): HasMany + { + return $this->hasMany(User::class); + } } diff --git a/database/migrations/2024_06_03_183521_create_profesions_table.php b/database/migrations/2024_06_03_183521_create_profesions_table.php index 727b730..794806e 100644 --- a/database/migrations/2024_06_03_183521_create_profesions_table.php +++ b/database/migrations/2024_06_03_183521_create_profesions_table.php @@ -13,7 +13,7 @@ public function up(): void { Schema::create('profesions', function (Blueprint $table) { $table->id(); - $table->string('profesion'); + $table->string('nombre'); $table->string('abreviatura'); $table->timestamps(); }); diff --git a/database/migrations/2024_06_03_183943_create_cargos_table.php b/database/migrations/2024_06_03_183943_create_cargos_table.php index a040eb2..7014a18 100644 --- a/database/migrations/2024_06_03_183943_create_cargos_table.php +++ b/database/migrations/2024_06_03_183943_create_cargos_table.php @@ -14,6 +14,7 @@ public function up(): void Schema::create('cargos', function (Blueprint $table) { $table->id(); $table->string('nombre'); + $table->timestamps(); }); } diff --git a/database/migrations/2024_06_03_184326_create_caracteristicas_table.php b/database/migrations/2024_06_03_184326_create_caracteristicas_table.php index 7eb0ce5..f1b57e2 100644 --- a/database/migrations/2024_06_03_184326_create_caracteristicas_table.php +++ b/database/migrations/2024_06_03_184326_create_caracteristicas_table.php @@ -14,6 +14,7 @@ public function up(): void Schema::create('caracteristicas', function (Blueprint $table) { $table->id(); $table->string('nombre'); + $table->timestamps(); }); } diff --git a/database/migrations/2024_06_03_194040_create_subgrupos_table.php b/database/migrations/2024_06_03_194040_create_subgrupos_table.php index dbca58c..7269f55 100644 --- a/database/migrations/2024_06_03_194040_create_subgrupos_table.php +++ b/database/migrations/2024_06_03_194040_create_subgrupos_table.php @@ -13,6 +13,7 @@ public function up(): void { Schema::create('subgrupos', function (Blueprint $table) { $table->id(); + $table->string('nombre'); $table->unsignedBigInteger('grupo_id')->nullable(); $table->unsignedBigInteger('subgrupo_id')->nullable(); $table->timestamps(); diff --git a/database/migrations/2024_06_10_194301_add_updated_at_to_cargos_table.php b/database/migrations/2024_06_10_194301_add_updated_at_to_cargos_table.php deleted file mode 100644 index 568bc06..0000000 --- a/database/migrations/2024_06_10_194301_add_updated_at_to_cargos_table.php +++ /dev/null @@ -1,32 +0,0 @@ -timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('cargos', function (Blueprint $table) { - $table->dropTimestamps(); - }); - } -} diff --git a/database/migrations/2024_06_12_202929_add_timestamps_to_caracteristicas_table.php b/database/migrations/2024_06_12_202929_add_timestamps_to_caracteristicas_table.php deleted file mode 100644 index bdeb1b3..0000000 --- a/database/migrations/2024_06_12_202929_add_timestamps_to_caracteristicas_table.php +++ /dev/null @@ -1,23 +0,0 @@ -timestamps(); - }); - } - - public function down() - { - Schema::table('caracteristicas', function (Blueprint $table) { - $table->dropTimestamps(); - }); - } -} - diff --git a/resources/views/adminGen/catalagos/caracteristicas.blade.php b/resources/views/adminGen/catalagos/caracteristicas.blade.php index aea6bec..7e20327 100644 --- a/resources/views/adminGen/catalagos/caracteristicas.blade.php +++ b/resources/views/adminGen/catalagos/caracteristicas.blade.php @@ -37,14 +37,15 @@
- - - - - - - - + + + + + + + + +
@@ -61,14 +62,15 @@
@@ -91,14 +93,15 @@
- - - - - - - - + + + + + + + + +
@@ -154,10 +157,10 @@ function editItem(id, nombre) { const modal = document.querySelector('#editModal'); const nombreInput = modal.querySelector('#nombreEditar'); - // Asigna el nombre actual del cargo al input del modal + // Asigna el nombre actual de la caracteristica al input del modal nombreInput.value = nombre; - // Agrega el ID del cargo al botón de guardar del modal + // Agrega el ID de la caracteristica al botón de guardar del modal const idInput = modal.querySelector('#idEditar'); idInput.value = id; diff --git a/resources/views/adminGen/catalagos/cargos.blade.php b/resources/views/adminGen/catalagos/cargos.blade.php index ed4ad79..40f9e31 100644 --- a/resources/views/adminGen/catalagos/cargos.blade.php +++ b/resources/views/adminGen/catalagos/cargos.blade.php @@ -37,15 +37,11 @@
- - - - - - - - - + + + + +
@@ -62,14 +58,11 @@
@@ -92,14 +85,11 @@
- - - - - - - - + + + + +
diff --git a/resources/views/adminGen/catalagos/grupos.blade.php b/resources/views/adminGen/catalagos/grupos.blade.php index 2f4121f..54d038c 100644 --- a/resources/views/adminGen/catalagos/grupos.blade.php +++ b/resources/views/adminGen/catalagos/grupos.blade.php @@ -37,14 +37,13 @@
- - - - - - - - + + + + + + +
@@ -61,14 +60,13 @@
@@ -91,14 +89,13 @@
- - - - - - - - + + + + + + +
@@ -154,10 +151,10 @@ function editItem(id, nombre) { const modal = document.querySelector('#editModal'); const nombreInput = modal.querySelector('#nombreEditar'); - // Asigna el nombre actual del cargo al input del modal + // Asigna el nombre actual del grupo al input del modal nombreInput.value = nombre; - // Agrega el ID del cargo al botón de guardar del modal + // Agrega el ID del grupo al botón de guardar del modal const idInput = modal.querySelector('#idEditar'); idInput.value = id; diff --git a/resources/views/adminGen/catalagos/profesion.blade.php b/resources/views/adminGen/catalagos/profesion.blade.php new file mode 100644 index 0000000..d774bf2 --- /dev/null +++ b/resources/views/adminGen/catalagos/profesion.blade.php @@ -0,0 +1,282 @@ + + + + + +
+
    +
  • + Dashboard +
  • +
  • + Catálogos +
  • +
  • + Profesiones +
  • +
+
+ + + + +
+
+
+ + + +
+
+
+ + + + + + + + + + +
IdAbreviaturaNombreAcciones
+ +
+
+ + + + + +
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 95e14f6..bb167cf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,12 +4,15 @@ //Middlewares use App\Http\Middleware\CheckBanned; //Controllers +use App\Http\Controllers\DependenciaController; use App\Http\Controllers\CargoController; +use App\Http\Controllers\ProfesionController; use App\Http\Controllers\CaracteristicasController; -use App\Http\Controllers\DependenciaController; use App\Http\Controllers\GruposController; +//aqui va subgrupos use App\Http\Controllers\UserController; + Route::get('/', function () { return view('welcome'); }); @@ -26,11 +29,16 @@ }); Route::prefix('catalogos')->name('catalogos.')->group(function () { - Route::get('/cargos', [CargoController::class, 'index'])->name('cargos.get'); - Route::post('/cargos', [CargoController::class, 'store'])->name('cargos.store'); - Route::put('/cargos', [CargoController::class, 'update'])->name('cargos.update'); + Route::get('/cargos', [CargoController::class, 'index'])->name('cargos.get'); + Route::post('/cargos', [CargoController::class, 'store'])->name('cargos.store'); + Route::put('/cargos', [CargoController::class, 'update'])->name('cargos.update'); Route::delete('/cargos/{id}', [CargoController::class, 'destroy'])->name('cargos.destroy'); + Route::get('/profesion', [ProfesionController::class, 'index'])->name('profesion.get'); + Route::post('/profesion', [ProfesionController::class, 'store'])->name('profesion.store'); + Route::put('/profesion/{id}', [ProfesionController::class, 'update'])->name('profesion.update'); + Route::delete('/profesion/{id}', [ProfesionController::class, 'destroy'])->name('profesion.destroy'); + Route::get('/caracteristicas', [CaracteristicasController::class, 'index'])->name('caracteristicas.get'); Route::post('/caracteristicas', [CaracteristicasController::class, 'store'])->name('caracteristicas.store'); Route::put('/caracteristicas', [CaracteristicasController::class, 'update'])->name('caracteristicas.update'); -- GitLab From f30f9c78692d6b1014141b0dff65c4a722527de9 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Wed, 19 Jun 2024 10:12:38 -0600 Subject: [PATCH 2/5] Correciones --- .../{profesionController.php => ProfesionController.php} | 2 +- app/Models/{profesion.php => Profesion.php} | 0 resources/views/adminGen/catalagos/profesion.blade.php | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) rename app/Http/Controllers/{profesionController.php => ProfesionController.php} (93%) rename app/Models/{profesion.php => Profesion.php} (100%) diff --git a/app/Http/Controllers/profesionController.php b/app/Http/Controllers/ProfesionController.php similarity index 93% rename from app/Http/Controllers/profesionController.php rename to app/Http/Controllers/ProfesionController.php index 7eb83d0..60f0675 100644 --- a/app/Http/Controllers/profesionController.php +++ b/app/Http/Controllers/ProfesionController.php @@ -10,7 +10,7 @@ class ProfesionController extends Controller public function index() { $profesiones = Profesion::all(); - return view('catalogos.profesion.index', compact('profesiones')); + return view('adminGen.catalagos.profesion', compact('profesiones')); } public function store(Request $request) diff --git a/app/Models/profesion.php b/app/Models/Profesion.php similarity index 100% rename from app/Models/profesion.php rename to app/Models/Profesion.php diff --git a/resources/views/adminGen/catalagos/profesion.blade.php b/resources/views/adminGen/catalagos/profesion.blade.php index d774bf2..ff7f16c 100644 --- a/resources/views/adminGen/catalagos/profesion.blade.php +++ b/resources/views/adminGen/catalagos/profesion.blade.php @@ -30,7 +30,7 @@
-
+ @csrf
@@ -53,7 +53,7 @@
-
+
@@ -140,7 +140,7 @@ - + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index bb167cf..4a6af14 100644 --- a/routes/web.php +++ b/routes/web.php @@ -35,7 +35,7 @@ Route::delete('/cargos/{id}', [CargoController::class, 'destroy'])->name('cargos.destroy'); Route::get('/profesion', [ProfesionController::class, 'index'])->name('profesion.get'); - Route::post('/profesion', [ProfesionController::class, 'store'])->name('profesion.store'); + Route::post('/profesiones', [ProfesionController::class, 'store'])->name('profesion.store'); Route::put('/profesion/{id}', [ProfesionController::class, 'update'])->name('profesion.update'); Route::delete('/profesion/{id}', [ProfesionController::class, 'destroy'])->name('profesion.destroy'); -- GitLab From bbe1e6c54d121ebb98101d20bf1e3771cc48f33d Mon Sep 17 00:00:00 2001 From: alekeyrivas Date: Thu, 20 Jun 2024 23:08:22 -0600 Subject: [PATCH 4/5] Ya funciona el catalago profesion --- app/Http/Controllers/ProfesionController.php | 8 +- .../adminGen/catalagos/profesion.blade.php | 204 +++++------------- routes/web.php | 2 +- 3 files changed, 64 insertions(+), 150 deletions(-) diff --git a/app/Http/Controllers/ProfesionController.php b/app/Http/Controllers/ProfesionController.php index d83f409..60f0675 100644 --- a/app/Http/Controllers/ProfesionController.php +++ b/app/Http/Controllers/ProfesionController.php @@ -19,11 +19,11 @@ public function store(Request $request) 'nombre' => 'required|string|max:255', 'abreviatura' => 'required|string|max:10', ]); - + Profesion::create($validated); - - return redirect()->route('catalogos.profesion.get')->with('success', 'Profesión creada exitosamente.'); - } + + return redirect()->route('catalogos.profesion.get'); + } public function update(Request $request, $id) { diff --git a/resources/views/adminGen/catalagos/profesion.blade.php b/resources/views/adminGen/catalagos/profesion.blade.php index 880d89a..2d1a02d 100644 --- a/resources/views/adminGen/catalagos/profesion.blade.php +++ b/resources/views/adminGen/catalagos/profesion.blade.php @@ -2,8 +2,9 @@ + -
+
  • Dashboard @@ -85,7 +86,7 @@ @method('DELETE') - +
@@ -93,122 +94,42 @@ - \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 4a6af14..bb167cf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -35,7 +35,7 @@ Route::delete('/cargos/{id}', [CargoController::class, 'destroy'])->name('cargos.destroy'); Route::get('/profesion', [ProfesionController::class, 'index'])->name('profesion.get'); - Route::post('/profesiones', [ProfesionController::class, 'store'])->name('profesion.store'); + Route::post('/profesion', [ProfesionController::class, 'store'])->name('profesion.store'); Route::put('/profesion/{id}', [ProfesionController::class, 'update'])->name('profesion.update'); Route::delete('/profesion/{id}', [ProfesionController::class, 'destroy'])->name('profesion.destroy'); -- GitLab From 925f71a1202aae5a223c2665b9b6f4d328620441 Mon Sep 17 00:00:00 2001 From: alekeyrivas Date: Fri, 21 Jun 2024 12:06:45 -0600 Subject: [PATCH 5/5] Ultimos detalles agregados --- resources/views/adminGen/catalagos/profesion.blade.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/views/adminGen/catalagos/profesion.blade.php b/resources/views/adminGen/catalagos/profesion.blade.php index 2d1a02d..15756f4 100644 --- a/resources/views/adminGen/catalagos/profesion.blade.php +++ b/resources/views/adminGen/catalagos/profesion.blade.php @@ -2,7 +2,6 @@ -
    @@ -161,8 +160,13 @@ // Script para DataTable document.addEventListener("DOMContentLoaded", function() { - var myTable = new simpleDatatables.DataTable("#myTable"); + var myTable = new simpleDatatables.DataTable("#myTable", { + paging: true, + perPageSelect: false, + searchable: true, + }); }); +
-- GitLab