diff --git a/app/Http/Controllers/HistorialController.php b/app/Http/Controllers/HistorialController.php index 86d4677..444dd4a 100644 --- a/app/Http/Controllers/HistorialController.php +++ b/app/Http/Controllers/HistorialController.php @@ -3,6 +3,10 @@ namespace App\Http\Controllers; use App\Models\Historial; + +use App\Models\Sede; +use App\Models\User; +use App\Models\Persona; use Illuminate\Http\Request; class HistorialController extends Controller @@ -11,14 +15,21 @@ class HistorialController extends Controller public function index() { // - $Historias = Historial::all(); + $Historias = Historial::with(['personas:id_persona,nombre_per,apellido_pa_per,apellido_ma_per','users.persona:id_persona,nombre_per,apellido_pa_per,apellido_ma_per','sede:id_sede,nombre_sede'])->get(); return view('admin.Historial.index',compact('Historias')); + + //return $Historias; } public function create() { // - return view('admin.Historial.create'); + $Sedes = Sede::all(); + $Users = User::with('persona')->get(); + + return view('admin.Historial.create',compact('Sedes','Users')); + + //return $Users; } public function store(Request $request) @@ -32,20 +43,30 @@ public function store(Request $request) } - public function show(Historial $Historial) + public function show($Historial) { // $Historia= Historial::find($Historial); + $Historial = Historial::with(['personas:id_persona,nombre_per,apellido_pa_per,apellido_ma_per','users.persona:id_persona,nombre_per,apellido_pa_per,apellido_ma_per','sede:id_sede,nombre_sede'])->find($Historial); + return View ('admin.Historial.show',compact('Historial')); + // + } - public function edit($historial) + public function edit($Historial) { // - $Historia= Historial::find($historial); - return View ('admin.Historial.edit',compact('Historia')); + $Sedes = Sede::all(); + $Users = User::with('persona')->get(); + $Historia = Historial::with(['personas:id_persona,nombre_per,apellido_pa_per,apellido_ma_per','users.persona:id_persona,nombre_per,apellido_pa_per,apellido_ma_per','sede:id_sede,nombre_sede'])->find($Historial); + + return View ('admin.Historial.edit',compact('Historia','Sedes','Users')); + + //return $Historia; + } diff --git a/app/Http/Controllers/PersonaController.php b/app/Http/Controllers/PersonaController.php index 27d7163..aa858a0 100644 --- a/app/Http/Controllers/PersonaController.php +++ b/app/Http/Controllers/PersonaController.php @@ -2,7 +2,9 @@ namespace App\Http\Controllers; +use App\Http\Requests\StorePersonaRequest; use App\Models\Persona; +use App\Models\TipoSangre; use Illuminate\Http\Request; use Psy\CodeCleaner\ReturnTypePass; @@ -16,6 +18,7 @@ class PersonaController extends Controller public function index() { $personas = Persona::get(); + //return $personas; return view('admin.Persona.index', compact('personas')); } @@ -26,7 +29,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')); } /** @@ -35,7 +40,7 @@ public function create() * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function store(Request $request) + public function store(StorePersonaRequest $request) { $datos = $request->all(); Persona::create($datos); 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/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 @@ + + */ + public function rules() + { + return [ + 'nombre_per'=> 'required|string|max:255', + 'apellido_pa_per'=> 'required|string|max:255', + 'apellido_ma_per'=> 'required|string|max:255', + 'ci_per'=> 'required', + 'cel_per'=> 'required', + 'fecha_nac'=> 'required|date', + 'num_seguro'=> 'nullable', + 'donante'=> 'required', + 'id_tipo_sangre'=> 'required', + 'id_pariente'=>'required' + ]; + } +} diff --git a/app/Models/Historial.php b/app/Models/Historial.php index 66aaa09..b7fe245 100644 --- a/app/Models/Historial.php +++ b/app/Models/Historial.php @@ -12,4 +12,20 @@ class Historial extends Model protected $table = 'historial'; protected $primaryKey = 'id_historial'; protected $fillable = ['id_persona','id_sede','id_medico','fecha_historial','detalles_historial']; + public function personas() + { + return $this->belongsTo(Persona::class,'id_persona'); + } + + public function users() + { + return $this->belongsTo(User::class,'id_medico'); + } + + public function sede() + { + return $this->belongsTo(Sede::class,'id_sede'); + } + + } 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/User.php b/app/Models/User.php index 7ac239b..6665665 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -43,4 +43,8 @@ class User extends Authenticatable protected $casts = [ 'email_verified_at' => 'datetime', ]; + public function persona() + { + return $this->belongsTo(Persona::class,'id_persona','id_persona'); + } } 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/Historial/create.blade.php b/resources/views/admin/Historial/create.blade.php index e325ee8..d00ca50 100644 --- a/resources/views/admin/Historial/create.blade.php +++ b/resources/views/admin/Historial/create.blade.php @@ -5,29 +5,52 @@
Registro de Historias
-
+ {!! csrf_field() !!} -
-
-
-
-
-
+ {{--
+
--}} -
-
+

+ + @foreach ( $Users as $user) + @if ($user->rol == 2 ) + + + @endif + @endforeach + + + + +
- {{--
- --}} + +
+ +
+
+ +
+

@@ -35,5 +58,4 @@
- diff --git a/resources/views/admin/Historial/edit.blade.php b/resources/views/admin/Historial/edit.blade.php index 75c1bf3..1fa554b 100644 --- a/resources/views/admin/Historial/edit.blade.php +++ b/resources/views/admin/Historial/edit.blade.php @@ -4,25 +4,58 @@
Editar Sede
-
+ {!! csrf_field() !!} @method("PATCH") -
-
-
-
-
-
+

+ + @foreach ( $Users as $user) + @if ($user->rol == 2 ) + @if ($user->persona->id_persona == $Historia->personas->id_persona) + + @else + + @endif + @endif + @endforeach + + + +
-
-
+
+ +
+
+ +
+

diff --git a/resources/views/admin/Historial/index.blade.php b/resources/views/admin/Historial/index.blade.php index dd5626c..c3fb968 100644 --- a/resources/views/admin/Historial/index.blade.php +++ b/resources/views/admin/Historial/index.blade.php @@ -28,12 +28,11 @@ @foreach ($Historias as $Historia) - - {{ $Historia['id_persona'] }} - {{ $Historia['id_sede'] }} - {{ $Historia['id_medico'] }} - {{ $Historia['fecha_historial'] }} - {{ $Historia['detalles_historial'] }} + {{ $Historia->personas->nombre_per ." ".$Historia->personas->apellido_pa_per ." ".$Historia->personas->apellido_ma_per }} + {{ $Historia->sede->nombre_sede }} + {{ $Historia->users->persona->nombre_per ." ". $Historia->users->persona->apellido_pa_per ." ". $Historia->users->persona->apellido_ma_per}} + {{ $Historia->fecha_historial}} + {{ $Historia->detalles_historial }}
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 }}

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 }}
-
+ {!! 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")
-
+

-
+

-
+

- diff --git a/resources/views/admin/Sedes/index.blade.php b/resources/views/admin/Sedes/index.blade.php index c17d730..ec94c41 100644 --- a/resources/views/admin/Sedes/index.blade.php +++ b/resources/views/admin/Sedes/index.blade.php @@ -1,7 +1,5 @@ - -
-
+
@@ -48,7 +46,5 @@
-
- diff --git a/resources/views/admin/tipo_relacion/create.blade.php b/resources/views/admin/tipo_relacion/create.blade.php index 2c03c24..d4ef9a2 100644 --- a/resources/views/admin/tipo_relacion/create.blade.php +++ b/resources/views/admin/tipo_relacion/create.blade.php @@ -6,12 +6,25 @@ @csrf
-
+
-
+
-
-
+
+
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 + - -
diff --git a/resources/views/admin/user/create.blade.php b/resources/views/admin/user/create.blade.php new file mode 100644 index 0000000..f765bf3 --- /dev/null +++ b/resources/views/admin/user/create.blade.php @@ -0,0 +1,34 @@ + + +
+
+
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