Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
aaaaaaaaaaa
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc15975 committed Nov 24, 2022
1 parent e07c575 commit cf5dd21
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 45 deletions.
33 changes: 27 additions & 6 deletions app/Http/Controllers/HistorialController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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;

}


Expand Down
16 changes: 16 additions & 0 deletions app/Models/Historial.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}


}
4 changes: 4 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
60 changes: 41 additions & 19 deletions resources/views/admin/Historial/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,57 @@
<div class="card-header">Registro de Historias</div>
<div class="card-body">

<form action="{{ url('Historial') }}" method="post">
<form action="{{ url('Historial') }}" class="was-validated" method="post">
{!! csrf_field() !!}
<label>Persona</label></br>
<input type="text" name="id_persona" id="id_persona" class="form-control"></br>
<label>Sede</label></br>
<input type="text" name="id_sede" id="id_sede" class="form-control"></br>
<label>Medico</label></br>
<input type="text" name="id_medico" id="id_medico" class="form-control"></br>
{{-- <label>Persona</label></br>
<input type="text" name="id_persona" id="id_persona" class="form-control"></br> --}}

<label>Fecha de la historia</label></br>
<input type="date" name="fecha_historial" id="fecha_historial" class="form-control"></br>
<label>Pacientes</label><br><select name="id_persona" id="id_persona" class="form-select" required>

<label>Detalles de la historia</label></br>
<input type="text" name="detalles_historial" id="detalles_historial" class="form-control"></br>
<option value="">Por favor selecione un paciente</option>
@foreach ( $Users as $user)
@if ($user->rol == 2 )

<option value="{{$user->persona->id_persona}}"> {{$user->persona->nombre_per ." ". $user->persona->apellido_pa_per ." ". $user->persona->apellido_ma_per }}</option>
@endif
@endforeach

</select>


<label>Sedes</label><br><select name="id_sede" id="id_sede" class="form-select" required>

<option value=""> Selecione una Sede </option>
@foreach ( $Sedes as $sede)

<option value="{{$sede->id_sede}}"> {{$sede->nombre_sede}}</option>

@endforeach

</select>

{{-- <label>Ciudad Sede</label></br>
<select class="form-select" name="ciudad_sede" id="ciudad_sede" aria-label="Default select example">
<option selected>Selecione la ciudad</option>
<option value="La Paz">La Paz</option>
<option value="Santa Cruz">Santa cruz</option>
<option value="Cochabamba">Cochabamba</option>
</select> --}}

<label>Medicos</label><br><select name="id_medico" id="id_medico" class="form-select" required>

<option value="">Por favor selecione un medico</option>
@foreach ( $Users as $user)
@if ($user->rol == 1 )
<option value="{{$user->id}}"> {{$user->persona->nombre_per ." ". $user->persona->apellido_pa_per ." ". $user->persona->apellido_ma_per }}</option>
@endif
@endforeach

</select>

<label>Fecha de la historia</label></br>
<input type="datetime-local" name="fecha_historial" id="fecha_historial" class="form-control" required></br>

<label>Detalles de la historia</label></br>
<input type="text" name="detalles_historial" id="detalles_historial" class="form-control" required></br>

<input type="submit" value="Save" class="btn btn-success"></br>
</form>

</div>
</div>
</div>

</x-layouts.app>
55 changes: 44 additions & 11 deletions resources/views/admin/Historial/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,58 @@
<div class="card-header">Editar Sede</div>
<div class="card-body">

<form action="{{ url('Historial/' .$Historia->id_historial) }}" method="post">
<form action="{{ url('Historial/' .$Historia->id_historial) }}" class="was-validated" method="post">
{!! csrf_field() !!}
@method("PATCH")
<input type="hidden" name="Id_Sede" id="Id_Sede" value="{{$Historia->id_historial}}" />

<label>Persona</label></br>
<input type="text" name="id_persona" id="id_persona" value="{{$Historia->id_persona}}" class="form-control"></br>
<label>Sede</label></br>
<input type="text" name="id_sede" id="id_sede" value="{{$Historia->id_sede}}" class="form-control"></br>
<label>Medico</label></br>
<input type="text" name="id_medico" id="id_medico" value="{{$Historia->id_medico}}" class="form-control"></br>
<label>Paciente</label><br><select name="id_persona" id="id_persona" class="form-select" required>

<label>Fecha de la historia</label></br>
<input type="date" name="fecha_historial" id="fecha_historial" value="{{$Historia->fecha_historial}}" class="form-control"></br>
<option value="">Por favor selecione un Paciente</option>
@foreach ( $Users as $user)
@if ($user->rol == 2 )
@if ($user->persona->id_persona == $Historia->personas->id_persona)
<option value="{{$user->persona->id_persona}}" selected> {{$user->persona->nombre_per ." ". $user->persona->apellido_pa_per ." ". $user->persona->apellido_ma_per }}</option>
@else
<option value="{{$user->persona->id_persona}}" > {{$user->persona->nombre_per ." ". $user->persona->apellido_pa_per ." ". $user->persona->apellido_ma_per }}</option>
@endif
@endif
@endforeach

</select>

<label>Sede</label><br><select name="id_sede" id="id_sede" class="form-select" required>

<option value="">Por favor selecione una Sede</option>
@foreach ( $Sedes as $sede)
@if ($sede->id_sede == $Historia->id_sede)
<option value="{{$sede->id_sede}}" selected> {{$sede->nombre_sede}}</option>
@else
<option value="{{$sede->id_sede}}" > {{$sede->nombre_sede}}</option>
@endif
@endforeach
</select>

<label>Detalles de la historia</label></br>
<input type="text" name="detalles_historial" id="detalles_historial" value="{{$Historia->detalles_historial}}" class="form-control"></br>

<label>Medicos</label><br><select name="id_medico" id="id_medico" class="form-select" required>

<option value="">Por favor selecione un Medico</option>
@foreach ( $Users as $user)
@if ($user->rol == 1 )
@if ($user->id == $Historia->users->id)
<option value="{{$user->id}}" selected> {{$user->persona->nombre_per ." ". $user->persona->apellido_pa_per ." ". $user->persona->apellido_ma_per }}</option>
@else
<option value="{{$user->id}}" > {{$user->persona->nombre_per ." ". $user->persona->apellido_pa_per ." ". $user->persona->apellido_ma_per }}</option>
@endif
@endif
@endforeach
</select>

<label>Fecha de la historia</label></br>
<input required type="datetime-local" name="fecha_historial" id="fecha_historial" value="{{$Historia->fecha_historial}}" class="form-control"></br>

<label>Detalles de la historia</label></br>
<input required type="text" name="detalles_historial" id="detalles_historial" value="{{$Historia->detalles_historial}}" class="form-control"></br>

<input type="submit" value="Update" class="btn btn-success"></br>
</form>
Expand Down
11 changes: 5 additions & 6 deletions resources/views/admin/Historial/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
<tbody>
@foreach ($Historias as $Historia)
<tr>

<td>{{ $Historia['id_persona'] }}</td>
<td>{{ $Historia['id_sede'] }}</td>
<td>{{ $Historia['id_medico'] }}</td>
<td>{{ $Historia['fecha_historial'] }}</td>
<td>{{ $Historia['detalles_historial'] }}</td>
<td>{{ $Historia->personas->nombre_per ." ".$Historia->personas->apellido_pa_per ." ".$Historia->personas->apellido_ma_per }}</td>
<td>{{ $Historia->sede->nombre_sede }}</td>
<td>{{ $Historia->users->persona->nombre_per ." ". $Historia->users->persona->apellido_pa_per ." ". $Historia->users->persona->apellido_ma_per}}</td>
<td>{{ $Historia->fecha_historial}}</td>
<td>{{ $Historia->detalles_historial }}</td>
<td>
<a href="{{ url('/Historial' . '/' . $Historia['id_historial']) }}" title="View Student"><button class="btn btn-info btn-sm"><i class="fa fa-eye" aria-hidden="true"></i> Mostrar</button></a> <a href="{{ url('/Historial' . '/' . $Historia->id_historial . '/edit') }}" title="Edit Student"><button class="btn btn-primary btn-sm"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Editar</button></a>
<form method="POST" action="{{ url('/Historial' . '/' . $Historia->id_historial) }}" accept-charset="UTF-8" style="display:inline">
Expand Down
7 changes: 4 additions & 3 deletions resources/views/admin/Historial/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<div class="card-body">

<div class="card-body">
<h5 class="card-title">Nombre de la Persona: {{ $Historial->id_persona }}</h5>
<p class="card-text">Nombre de la Sede : {{ $Historial->id_sede }}</p>
<p class="card-text">Nombre del Medico : {{ $Historial->id_medico }}</p>
<h5 class="card-title">Datos de la Historia</h5>
<p class="card-text">Nombre de la Persona: {{ $Historial->personas->nombre_per ." ".$Historial->personas->apellido_pa_per ." ".$Historial->personas->apellido_ma_per }}</p>
<p class="card-text">Nombre de la Sede : {{ $Historial->sede->nombre_sede }}</p>
<p class="card-text">Nombre del Medico : {{ $Historial->users->persona->nombre_per ." ". $Historial->users->persona->apellido_pa_per ." ". $Historial->users->persona->apellido_ma_per }}</p>
<p class="card-text">Fecha del Historial: {{ $Historial->fecha_historial }}</p>
<p class="card-text">Detalles de la Historia: {{ $Historial->detalles_historial }}</p>
</div>
Expand Down

0 comments on commit cf5dd21

Please sign in to comment.