From a7d52e3d0b8a81b52fe02f8b8f62aaf882603e83 Mon Sep 17 00:00:00 2001 From: rats4final Date: Thu, 24 Nov 2022 02:45:01 -0400 Subject: [PATCH 1/6] Mejoras en crud persona con sus relaciones asi como elcrud tipo relaciones --- app/Http/Controllers/PersonaController.php | 6 ++++- .../Controllers/TipoRelacionController.php | 5 ++++- app/Models/Persona.php | 11 +++++++++- app/Models/TipoSangre.php | 2 +- ...08_23_053433_create_tipo_sangres_table.php | 1 - .../2022_09_22_152240_create_personas.php | 2 ++ ...2022_09_26_151743_create_tipo_relacion.php | 2 +- .../views/admin/Persona/create.blade.php | 22 ++++++++++++++----- resources/views/admin/Persona/index.blade.php | 2 ++ resources/views/admin/Sedes/index.blade.php | 6 +---- .../admin/tipo_relacion/create.blade.php | 21 ++++++++++++++---- 11 files changed, 59 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/PersonaController.php b/app/Http/Controllers/PersonaController.php index 27d7163..11cf931 100644 --- a/app/Http/Controllers/PersonaController.php +++ b/app/Http/Controllers/PersonaController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Models\Persona; +use App\Models\TipoSangre; use Illuminate\Http\Request; use Psy\CodeCleaner\ReturnTypePass; @@ -16,6 +17,7 @@ class PersonaController extends Controller public function index() { $personas = Persona::get(); + //return $personas; return view('admin.Persona.index', compact('personas')); } @@ -26,7 +28,9 @@ public function index() */ public function create() { - return view('admin.Persona.create'); + $personas = Persona::get(); + $tipos_sangre = TipoSangre::get(); + return view('admin.Persona.create', compact('tipos_sangre','personas')); } /** diff --git a/app/Http/Controllers/TipoRelacionController.php b/app/Http/Controllers/TipoRelacionController.php index 4916bd6..644aa3d 100644 --- a/app/Http/Controllers/TipoRelacionController.php +++ b/app/Http/Controllers/TipoRelacionController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\Persona; use App\Models\TipoRelacion; use Illuminate\Http\Request; @@ -15,6 +16,7 @@ class TipoRelacionController extends Controller public function index() { $TipoRelaciones = TipoRelacion::get(); + //return $TipoRelaciones; return view('admin.tipo_relacion.index', compact('TipoRelaciones')); } @@ -25,7 +27,8 @@ public function index() */ public function create() { - return view('admin.tipo_relacion.create'); + $personas = Persona::get(); + return view('admin.tipo_relacion.create', compact('personas')); } /** diff --git a/app/Models/Persona.php b/app/Models/Persona.php index c27fdae..c80556e 100644 --- a/app/Models/Persona.php +++ b/app/Models/Persona.php @@ -19,10 +19,19 @@ class Persona extends Model 'fecha_nac', 'num_seguro', 'donante', - 'id_tipo_sangre' + 'id_tipo_sangre', + 'id_pariente' + ]; + protected $dates = [ + 'fecha_nac' ]; public function tipo_sangre(){ return $this->belongsTo(TipoSangre::class,'id_tipo_sangre','id_tipo_sangre'); } + + public function pariente(){ + return $this->belongsTo(Persona::class,'id_pariente','id_persona'); + } + } diff --git a/app/Models/TipoSangre.php b/app/Models/TipoSangre.php index f26310b..58bd40d 100644 --- a/app/Models/TipoSangre.php +++ b/app/Models/TipoSangre.php @@ -9,7 +9,7 @@ class TipoSangre extends Model { use HasFactory; - protected $table = 'tipo_sangre'; + protected $table = 'tipos_sangre'; protected $primaryKey = 'id_tipo_sangre'; protected $fillable = ['nombre_tipo_sangre','descripcion_tipo_sangre','rareza_tipo_sangre']; diff --git a/database/migrations/2022_08_23_053433_create_tipo_sangres_table.php b/database/migrations/2022_08_23_053433_create_tipo_sangres_table.php index c7a360d..2434997 100644 --- a/database/migrations/2022_08_23_053433_create_tipo_sangres_table.php +++ b/database/migrations/2022_08_23_053433_create_tipo_sangres_table.php @@ -13,7 +13,6 @@ */ public function up() { - Schema::create('tipos_sangre', function (Blueprint $table) { $table->increments('id_tipo_sangre'); $table->string('nombre_tipo_sangre')->unique(); diff --git a/database/migrations/2022_09_22_152240_create_personas.php b/database/migrations/2022_09_22_152240_create_personas.php index d20801c..1810792 100644 --- a/database/migrations/2022_09_22_152240_create_personas.php +++ b/database/migrations/2022_09_22_152240_create_personas.php @@ -25,6 +25,8 @@ public function up() $table->date('fecha_nac'); $table->Integer('id_tipo_sangre')->unsigned(); $table->foreign('id_tipo_sangre')->references('id_tipo_sangre')->on('tipos_sangre'); + $table->integer('id_pariente')->unsigned()->nullable(); + $table->foreign('id_pariente')->references('id_persona')->on('personas'); $table->timestamps(); }); } diff --git a/database/migrations/2022_09_26_151743_create_tipo_relacion.php b/database/migrations/2022_09_26_151743_create_tipo_relacion.php index 9a02dbd..af7710e 100644 --- a/database/migrations/2022_09_26_151743_create_tipo_relacion.php +++ b/database/migrations/2022_09_26_151743_create_tipo_relacion.php @@ -14,7 +14,7 @@ public function up() { Schema::create('tipo_relacion', function (Blueprint $table) { - $table->increments('id_tipo_rel'); + $table->increments('id_tipo_relacion'); $table->string('relacion'); $table->Integer('id_persona')->unsigned(); $table->foreign('id_persona')->references('id_persona')->on('personas'); diff --git a/resources/views/admin/Persona/create.blade.php b/resources/views/admin/Persona/create.blade.php index 7c4c528..fc85774 100644 --- a/resources/views/admin/Persona/create.blade.php +++ b/resources/views/admin/Persona/create.blade.php @@ -12,18 +12,28 @@


-
+

-
+



-
+
+
+
+
+


-
-
-
+
diff --git a/resources/views/admin/Persona/index.blade.php b/resources/views/admin/Persona/index.blade.php index a591aac..cd1930c 100644 --- a/resources/views/admin/Persona/index.blade.php +++ b/resources/views/admin/Persona/index.blade.php @@ -25,6 +25,7 @@ # Seguro Es donante Tipo Sangre + Pariente Acciones @@ -40,6 +41,7 @@ {{ $persona->num_seguro }} {{ $persona->donante }} {{ $persona->tipo_sangre->nombre_tipo_sangre }} + {{ $persona->pariente->nombre_per }}
diff --git a/resources/views/admin/Historial/show.blade.php b/resources/views/admin/Historial/show.blade.php index 27117f4..5fa0c33 100644 --- a/resources/views/admin/Historial/show.blade.php +++ b/resources/views/admin/Historial/show.blade.php @@ -4,9 +4,10 @@
-
Nombre de la Persona: {{ $Historial->id_persona }}
-

Nombre de la Sede : {{ $Historial->id_sede }}

-

Nombre del Medico : {{ $Historial->id_medico }}

+
Datos de la Historia
+

Nombre de la Persona: {{ $Historial->personas->nombre_per ." ".$Historial->personas->apellido_pa_per ." ".$Historial->personas->apellido_ma_per }}

+

Nombre de la Sede : {{ $Historial->sede->nombre_sede }}

+

Nombre del Medico : {{ $Historial->users->persona->nombre_per ." ". $Historial->users->persona->apellido_pa_per ." ". $Historial->users->persona->apellido_ma_per }}

Fecha del Historial: {{ $Historial->fecha_historial }}

Detalles de la Historia: {{ $Historial->detalles_historial }}

From 832d9b23e5dbcc98126a7836d6ebc0c8b111fd63 Mon Sep 17 00:00:00 2001 From: Marc15975 <91290441+Marc15975@users.noreply.github.com> Date: Thu, 24 Nov 2022 03:52:56 -0400 Subject: [PATCH 4/6] Sedes y Historial --- resources/views/admin/Sedes/create.blade.php | 12 ++++++------ resources/views/admin/Sedes/edit.blade.php | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/resources/views/admin/Sedes/create.blade.php b/resources/views/admin/Sedes/create.blade.php index bc83210..10a42f3 100644 --- a/resources/views/admin/Sedes/create.blade.php +++ b/resources/views/admin/Sedes/create.blade.php @@ -3,18 +3,18 @@
Registro de Sedes
- + {!! csrf_field() !!}
-
+

-
+

-
+

- + diff --git a/resources/views/admin/Sedes/edit.blade.php b/resources/views/admin/Sedes/edit.blade.php index 09dc43c..ddac5d7 100644 --- a/resources/views/admin/Sedes/edit.blade.php +++ b/resources/views/admin/Sedes/edit.blade.php @@ -4,19 +4,19 @@
Editar Sede
- + {!! csrf_field() !!} @method("PATCH")
-
+

-
+

-
+

- From 88126c3d997a77cdfd5356288beb5667c27c6fca Mon Sep 17 00:00:00 2001 From: Lara121801 Date: Thu, 24 Nov 2022 10:57:58 -0400 Subject: [PATCH 5/6] CRUD-USER --- app/Http/Controllers/UsuarioController.php | 83 +++++++++++++++++++++ resources/views/admin/user/create.blade.php | 34 +++++++++ resources/views/admin/user/edit.blade.php | 0 3 files changed, 117 insertions(+) create mode 100644 app/Http/Controllers/UsuarioController.php create mode 100644 resources/views/admin/user/create.blade.php create mode 100644 resources/views/admin/user/edit.blade.php diff --git a/app/Http/Controllers/UsuarioController.php b/app/Http/Controllers/UsuarioController.php new file mode 100644 index 0000000..2c656fa --- /dev/null +++ b/app/Http/Controllers/UsuarioController.php @@ -0,0 +1,83 @@ + + +
+
+
Registro de Usuario
+
+ + {!! csrf_field() !!} +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+
+
+ + diff --git a/resources/views/admin/user/edit.blade.php b/resources/views/admin/user/edit.blade.php new file mode 100644 index 0000000..e69de29 From ed3a2ddd913b7fe1671c539e8a67876457e4eea1 Mon Sep 17 00:00:00 2001 From: rats4final <80012704+rats4final@users.noreply.github.com> Date: Thu, 24 Nov 2022 15:21:51 -0400 Subject: [PATCH 6/6] old tipos sangre --- app/Models/TipoSangre.php | 2 +- .../views/admin/tipo_relacion/index.blade.php | 66 ++++++++++--------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/app/Models/TipoSangre.php b/app/Models/TipoSangre.php index f26310b..58bd40d 100644 --- a/app/Models/TipoSangre.php +++ b/app/Models/TipoSangre.php @@ -9,7 +9,7 @@ class TipoSangre extends Model { use HasFactory; - protected $table = 'tipo_sangre'; + protected $table = 'tipos_sangre'; protected $primaryKey = 'id_tipo_sangre'; protected $fillable = ['nombre_tipo_sangre','descripcion_tipo_sangre','rareza_tipo_sangre']; diff --git a/resources/views/admin/tipo_relacion/index.blade.php b/resources/views/admin/tipo_relacion/index.blade.php index dfe488c..b7bd315 100644 --- a/resources/views/admin/tipo_relacion/index.blade.php +++ b/resources/views/admin/tipo_relacion/index.blade.php @@ -7,7 +7,8 @@

Tipo Relacion

- + Nueva Relacion
@@ -16,41 +17,42 @@ - - - - - - + + + + + + - @foreach ($TipoRelaciones as $TipoRelacion) - - - - - + + + - - @endforeach + class="fa fa-trash-o" aria-hidden="true"> + Borrar + + + + @endforeach
Todas la relaciones
RelacionPersona 1Persona 2Acciones
RelacionPersona 1Persona 2Acciones
{{ $TipoRelacion->relacion }}{{ $TipoRelacion->persona->nombre_per }}{{ $TipoRelacion->pariente->nombre_per }} - - -
- @method('DELETE') - @csrf -
{{ $TipoRelacion->relacion }}{{ $TipoRelacion->persona->nombre_per }}{{ $TipoRelacion->pariente->nombre_per }} + + + + @method('DELETE') + @csrf + - -