From cf5dd21a88cb13be782a0fa74b82a7921d077c5d Mon Sep 17 00:00:00 2001 From: Marc15975 <91290441+Marc15975@users.noreply.github.com> Date: Thu, 24 Nov 2022 03:48:40 -0400 Subject: [PATCH] aaaaaaaaaaa --- app/Http/Controllers/HistorialController.php | 33 ++++++++-- app/Models/Historial.php | 16 +++++ app/Models/User.php | 4 ++ .../views/admin/Historial/create.blade.php | 60 +++++++++++++------ .../views/admin/Historial/edit.blade.php | 55 +++++++++++++---- .../views/admin/Historial/index.blade.php | 11 ++-- .../views/admin/Historial/show.blade.php | 7 ++- 7 files changed, 141 insertions(+), 45 deletions(-) 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/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/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/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 @@