From 82bf885e6618fb61c6cd04ca5880877a849764a7 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 10 Jun 2024 18:03:04 -0600 Subject: [PATCH 01/16] Controlador inicial --- .../Controllers/DependenciaController.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 app/Http/Controllers/DependenciaController.php diff --git a/app/Http/Controllers/DependenciaController.php b/app/Http/Controllers/DependenciaController.php new file mode 100644 index 0000000..33707fe --- /dev/null +++ b/app/Http/Controllers/DependenciaController.php @@ -0,0 +1,66 @@ + $dependencias]); + } + + /** + * 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(Dependencia $dependencia) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(Dependencia $dependencia) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, Dependencia $dependencia) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Dependencia $dependencia) + { + // + } +} -- GitLab From 65743b1cadc385ddf1fdf364a74c30e159df4dd6 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 10 Jun 2024 18:03:23 -0600 Subject: [PATCH 02/16] Modelo de la dependencia --- app/Models/Dependencia.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/Models/Dependencia.php diff --git a/app/Models/Dependencia.php b/app/Models/Dependencia.php new file mode 100644 index 0000000..3c95b12 --- /dev/null +++ b/app/Models/Dependencia.php @@ -0,0 +1,22 @@ +hasMany(User::class); + } +} -- GitLab From e2531b4c7641da3821dfdb65f42dbad41e0e84e9 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 10 Jun 2024 18:03:37 -0600 Subject: [PATCH 03/16] =?UTF-8?q?Migraci=C3=B3n=20de=20la=20dependencia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...06_10_154242_create_dependencias_table.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 database/migrations/2024_06_10_154242_create_dependencias_table.php diff --git a/database/migrations/2024_06_10_154242_create_dependencias_table.php b/database/migrations/2024_06_10_154242_create_dependencias_table.php new file mode 100644 index 0000000..718a95c --- /dev/null +++ b/database/migrations/2024_06_10_154242_create_dependencias_table.php @@ -0,0 +1,34 @@ +id(); + $table->string('nombre'); + $table->timestamps(); + }); + + Schema::table('users', function(Blueprint $table){ + $table->unsignedBigInteger('dependencia_id'); + + $table->foreign('dependencia_id')->references('id')->on('dependencias'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('dependencias'); + } +}; -- GitLab From cb27f7405e3954cb22527d8b9b742b138a0709a8 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 10 Jun 2024 18:03:51 -0600 Subject: [PATCH 04/16] Vista principal del catalogo de dependencias --- .../adminGen/catalogos/dependencias.blade.php | 179 +++++++++++++++++- 1 file changed, 174 insertions(+), 5 deletions(-) diff --git a/resources/views/adminGen/catalogos/dependencias.blade.php b/resources/views/adminGen/catalogos/dependencias.blade.php index 6f36f7b..392a870 100644 --- a/resources/views/adminGen/catalogos/dependencias.blade.php +++ b/resources/views/adminGen/catalogos/dependencias.blade.php @@ -1,17 +1,186 @@ - -
+ +
  • Dashboard
  • - Analytics + Catálogos +
  • +
  • + Dependencias
-
- +
+
+
+ + + + +
+
+ + + + + + + + +
IdNombreAcciones
+ + + -- GitLab From 94c4730c76f80ed52bf28a53fd2d5bbcef65817f Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 10 Jun 2024 18:04:06 -0600 Subject: [PATCH 05/16] Cambio en el seeder de los usuarios --- database/seeders/UserSeeder.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index 74e53e9..48dba52 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -5,6 +5,7 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use App\Models\User; +use App\Models\Dependencia; use Illuminate\Support\Facades\Hash; use Spatie\Permission\Models\Role; @@ -21,12 +22,14 @@ public function run(): void $roleAdmin = Role::create(['name' => 'admin']); $roleCap = Role::create(['name' => 'capturista']); $roleLector = Role::create(['name' => 'lector']); + $dependencia = Dependencia::create(['nombre' => 'Administración']); $user = User::create([ 'name' => 'Administración general', 'username' => 'admingen', 'active' => 1, 'password' => Hash::make('12345678'), + 'dependencia_id' => 1, ]); $user->assignRole('admingen'); @@ -35,6 +38,7 @@ public function run(): void 'username' => 'admin', 'active' => 1, 'password' => Hash::make('12345678'), + 'dependencia_id' => 1, ]); $user->assignRole('admin'); @@ -43,6 +47,7 @@ public function run(): void 'username' => 'capturista', 'active' => 1, 'password' => Hash::make('12345678'), + 'dependencia_id' => 1, ]); $user->assignRole('capturista'); @@ -51,6 +56,7 @@ public function run(): void 'username' => 'lector', 'active' => 1, 'password' => Hash::make('12345678'), + 'dependencia_id' => 1, ]); $user->assignRole('lector'); -- GitLab From ba8b13d14cf5329012574dc76ad25b5de2191601 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 10 Jun 2024 18:04:28 -0600 Subject: [PATCH 06/16] Agregar las rutas de dependencias --- routes/web.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routes/web.php b/routes/web.php index ad319f1..a3553c6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,7 +1,10 @@ name('dashboard'); }); + +Route::get('/catalogos/dependencias', [DependenciaController::class, 'index']); \ No newline at end of file -- GitLab From 63d4badeda3c6fc79170c505078d54368f2d6f70 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 10 Jun 2024 20:56:56 -0600 Subject: [PATCH 07/16] Modal para agregar dependencia, botones de acciones en las tablas y tabla dinamica con datos de la base de datos --- .../adminGen/catalogos/dependencias.blade.php | 251 ++++++++---------- 1 file changed, 114 insertions(+), 137 deletions(-) diff --git a/resources/views/adminGen/catalogos/dependencias.blade.php b/resources/views/adminGen/catalogos/dependencias.blade.php index 392a870..161b757 100644 --- a/resources/views/adminGen/catalogos/dependencias.blade.php +++ b/resources/views/adminGen/catalogos/dependencias.blade.php @@ -1,6 +1,8 @@ + +
  • @@ -16,73 +18,54 @@
    - - - - +
    + + + +
    @@ -93,94 +76,88 @@ +
    Acciones
    +
- + -
+ \ No newline at end of file -- GitLab From 88671ffa5600fcdab40b1572a6f0fcc2bdf7e978 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 10 Jun 2024 20:57:14 -0600 Subject: [PATCH 08/16] Dump and die de informacion recabada por el formulario --- app/Http/Controllers/DependenciaController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/DependenciaController.php b/app/Http/Controllers/DependenciaController.php index 33707fe..1650998 100644 --- a/app/Http/Controllers/DependenciaController.php +++ b/app/Http/Controllers/DependenciaController.php @@ -29,7 +29,7 @@ public function create() */ public function store(Request $request) { - // + dd($request); } /** -- GitLab From a7d575af3f4607fb6b2e05bc8b0b105ed1889396 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 10 Jun 2024 20:57:41 -0600 Subject: [PATCH 09/16] Grupo de rutas de las dependencias en espera de pasarle el middleware de roles y checkbaned --- routes/web.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index a3553c6..16cefc0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -21,4 +21,9 @@ })->name('dashboard'); }); -Route::get('/catalogos/dependencias', [DependenciaController::class, 'index']); \ No newline at end of file + +Route::name('catalogos.')->group(function () { + Route::get('/catalogos/dependencias', [DependenciaController::class, 'index'])->name('dependencias.get'); + Route::post('/catalogos/dependencias', [DependenciaController::class, 'store'])->name('dependencias.store'); +}); + -- GitLab From 2411e0dd07079e32a4b5efb890b4cd69527343ee Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Tue, 11 Jun 2024 23:56:11 -0600 Subject: [PATCH 10/16] Ruta de actualizar dependencias --- routes/web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/web.php b/routes/web.php index 16cefc0..07843a7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,5 +25,6 @@ Route::name('catalogos.')->group(function () { Route::get('/catalogos/dependencias', [DependenciaController::class, 'index'])->name('dependencias.get'); Route::post('/catalogos/dependencias', [DependenciaController::class, 'store'])->name('dependencias.store'); + Route::put('/catalogos/dependencias', [DependenciaController::class, 'update'])->name('dependencias.update'); }); -- GitLab From b409ca675406491924fa1ed1f5c8e97214ff3f69 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Tue, 11 Jun 2024 23:56:24 -0600 Subject: [PATCH 11/16] Almacenamiento de datos en la db --- app/Http/Controllers/DependenciaController.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/DependenciaController.php b/app/Http/Controllers/DependenciaController.php index 1650998..2a08e5d 100644 --- a/app/Http/Controllers/DependenciaController.php +++ b/app/Http/Controllers/DependenciaController.php @@ -29,7 +29,14 @@ public function create() */ public function store(Request $request) { - dd($request); + $validated = $request->validate([ + 'nombre' => 'required|max:150', + ]); + + $dependencia = new Dependencia; + $dependencia->nombre = $request->nombre; + $dependencia->save(); + return redirect()->route('catalogos.dependencias.get')->with('Dependencia creada correctamente.'); } /** @@ -53,7 +60,14 @@ public function edit(Dependencia $dependencia) */ public function update(Request $request, Dependencia $dependencia) { - // + $validated = $request->validate([ + 'id' => 'required:min:1', + 'nombre' => 'required|max:150', + ]); + $dependencia = Dependencia::find($request->id); + $dependencia->nombre = $request->nombre; + $dependencia->save(); + return redirect()->route('catalogos.dependencias.get')->with('success', 'Dependencia actualizada correctamente.'); } /** -- GitLab From ae7b4b871f694bf01473d51047799dd28bef0df6 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Tue, 11 Jun 2024 23:56:39 -0600 Subject: [PATCH 12/16] Agregamos la llave primaria al modelo --- app/Models/Dependencia.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Models/Dependencia.php b/app/Models/Dependencia.php index 3c95b12..a7d772b 100644 --- a/app/Models/Dependencia.php +++ b/app/Models/Dependencia.php @@ -12,6 +12,8 @@ class Dependencia extends Model { use HasFactory; + protected $primaryKey = 'id'; + protected $fillable = [ 'nombre', ]; -- GitLab From d6d55e8d9e4a470bb4a7b8f0de0e656ff3e41fc3 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Tue, 11 Jun 2024 23:56:57 -0600 Subject: [PATCH 13/16] Plantilla base --- .../adminGen/catalogos/dependencias.blade.php | 169 +++++++++++++++--- 1 file changed, 142 insertions(+), 27 deletions(-) diff --git a/resources/views/adminGen/catalogos/dependencias.blade.php b/resources/views/adminGen/catalogos/dependencias.blade.php index 161b757..e00c49e 100644 --- a/resources/views/adminGen/catalogos/dependencias.blade.php +++ b/resources/views/adminGen/catalogos/dependencias.blade.php @@ -16,15 +16,62 @@
+
+ + \ No newline at end of file -- GitLab From d8d520ba9c9a3bafbaa72944dfd5d473c509c2c6 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Wed, 12 Jun 2024 10:40:08 -0600 Subject: [PATCH 14/16] Ruta para eliminar dependencia --- routes/web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/web.php b/routes/web.php index 07843a7..dd0beda 100644 --- a/routes/web.php +++ b/routes/web.php @@ -26,5 +26,6 @@ Route::get('/catalogos/dependencias', [DependenciaController::class, 'index'])->name('dependencias.get'); Route::post('/catalogos/dependencias', [DependenciaController::class, 'store'])->name('dependencias.store'); Route::put('/catalogos/dependencias', [DependenciaController::class, 'update'])->name('dependencias.update'); + Route::delete('/catalogos/dependencias/{id}', [DependenciaController::class, 'destroy'])->name('dependencias.destroy'); }); -- GitLab From 2eaac55907cfbc3e84c4080a4071710515bdb233 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Wed, 12 Jun 2024 10:40:31 -0600 Subject: [PATCH 15/16] Metodo de eliminar dependencia y correcciones en mensajes --- app/Http/Controllers/DependenciaController.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/DependenciaController.php b/app/Http/Controllers/DependenciaController.php index 2a08e5d..d39ac02 100644 --- a/app/Http/Controllers/DependenciaController.php +++ b/app/Http/Controllers/DependenciaController.php @@ -36,7 +36,7 @@ public function store(Request $request) $dependencia = new Dependencia; $dependencia->nombre = $request->nombre; $dependencia->save(); - return redirect()->route('catalogos.dependencias.get')->with('Dependencia creada correctamente.'); + return redirect()->route('catalogos.dependencias.get')->with('success', 'Dependencia creada correctamente.'); } /** @@ -73,8 +73,14 @@ public function update(Request $request, Dependencia $dependencia) /** * Remove the specified resource from storage. */ - public function destroy(Dependencia $dependencia) + public function destroy($id) { - // + try{ + $dependencia = Dependencia::findOrFail($id); + $dependencia->delete(); + return redirect()->route('catalogos.dependencias.get')->with('success', 'Dependencia eliminada correctamente.'); + }catch(\Exception $e){ + return redirect()->route('catalogos.dependencias.get')->withErrors('Error al eliminar la dependencia:' . $e->getMessage()); + } } } -- GitLab From 866c5766230480b0854628ab38a649d1365765ae Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Wed, 12 Jun 2024 10:41:40 -0600 Subject: [PATCH 16/16] Inputs requeridos, crear boton de eliminar y eliminar funciones obsoletas --- .../adminGen/catalogos/dependencias.blade.php | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/resources/views/adminGen/catalogos/dependencias.blade.php b/resources/views/adminGen/catalogos/dependencias.blade.php index e00c49e..1246fae 100644 --- a/resources/views/adminGen/catalogos/dependencias.blade.php +++ b/resources/views/adminGen/catalogos/dependencias.blade.php @@ -47,7 +47,7 @@
- +
@@ -103,7 +103,7 @@
- +
@@ -146,15 +146,15 @@ function renderActions(id, nombre) { return `
- +
+ @csrf + @method('DELETE') + +
`; } - function deleteItem(id) { - console.log('Eliminar', id); - } - function editItem(id, nombre) { const modal = document.querySelector('#editModal'); const nombreInput = modal.querySelector('#nombreEditar'); @@ -195,13 +195,9 @@ function editItem(id, nombre) { labels: { perPage: "{select}" }, - layout: { - top: "{search}", - bottom: "{info}{select}{pager}" - } + rowId: 'Hola' }); - window.deleteItem = deleteItem; window.editItem = editItem; }); @@ -215,10 +211,10 @@ function editItem(id, nombre) { })); }); - showMessage = (msg = 'Example notification text.', position = 'bottom-start', showCloseButton = true, closeButtonHtml = '', duration = 3000, type = 'success') => { + showMessage = (msg = 'Example notification text.', position = 'top-end', showCloseButton = true, closeButtonHtml = '', duration = 3000, type = 'success') => { const toast = window.Swal.mixin({ toast: true, - position: position || 'bottom-start', + position: position || 'top-end', showConfirmButton: false, timer: duration, showCloseButton: showCloseButton, @@ -263,16 +259,17 @@ function editItem(id, nombre) { }); }; - // Verifica si hay un mensaje de éxito en la sesión - @if(session('success')) + document.addEventListener('DOMContentLoaded', function() { + @if(session('success')) // Muestra el mensaje de éxito utilizando showMessage - showMessage('{{ session('success') }}', 'bottom-start', true, '', 3000, 'success'); - @endif + showMessage("{{ session('success') }}", 'top-end', true, '', 3000, 'success'); + @endif - // Verifica si hay un mensaje de error en la sesión - @if(session('error')) - // Muestra el mensaje de error utilizando showMessage - showMessage('{{ session('error') }}', 'bottom-start', true, '', 3000, 'error'); - @endif + @if($errors -> any()) + @foreach($errors -> all() as $error) + showMessage("{{$error}}", 'top-end', true, '', 3000, 'error'); + @endforeach + @endif + });
\ No newline at end of file -- GitLab