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 }}