This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
497 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Models\User; | ||
use App\Models\Persona; | ||
use App\Models\TipoSangre; | ||
use App\Models\Especialidad; | ||
use App\Models\Usario_has_especialidad; | ||
|
||
class MedicoController extends Controller | ||
{ | ||
|
||
public function index() | ||
{ | ||
// | ||
$usuarios = User::with(['persona.has_especialidad.especialidad'])->get(); | ||
|
||
return view('admin.User_medico.index',compact('usuarios')); | ||
} | ||
|
||
|
||
public function create() | ||
{ | ||
// | ||
$tipos_sangre = TipoSangre::get(); | ||
$especialidades = Especialidad::all(); | ||
|
||
|
||
return view('admin.User_medico.create',compact('tipos_sangre','especialidades')); | ||
} | ||
|
||
|
||
public function store(Request $request) | ||
{ | ||
$datos = $request->all(); | ||
Persona::create($datos); | ||
$id = Persona::latest('id_persona')->first(); | ||
//return to_route('personas.index'); | ||
$datos1 = ['rol'=>"1", 'estado'=>1, 'id_persona'=>$id->id_persona]; | ||
$datosUser = array_merge($datos, $datos1); | ||
User::create($datosUser); | ||
$id_user= User::latest('id')->first(); //id | ||
$datos12 = ['id_medico'=>$id_user->id]; | ||
|
||
foreach ($request["especialidades"] as $req){ | ||
Usario_has_especialidad::create([ | ||
'id_especialidad' => $req[0], | ||
'id_medico'=>$id_user->id | ||
]); | ||
} | ||
return redirect('/Medico'); | ||
|
||
} | ||
|
||
|
||
public function show($id) | ||
{ | ||
// | ||
} | ||
|
||
|
||
public function edit($id) | ||
{ | ||
// | ||
|
||
$usuarios = User::with(['persona.has_especialidad.especialidad'])->find($id); | ||
|
||
$tipos_sangre = TipoSangre::get(); | ||
$especialidades = Especialidad::all(); | ||
|
||
return view('admin.User_medico.edit',compact('usuarios','tipos_sangre','especialidades')); | ||
} | ||
|
||
|
||
public function update(Request $request, $id) | ||
{ | ||
// | ||
$input = $request->all(); | ||
return redirect('/Medico'); | ||
} | ||
|
||
|
||
public function destroy(Request $request,$medico) | ||
{ | ||
// | ||
$input = $request->all(); | ||
|
||
$usuarios = User::find($medico); | ||
|
||
$estado = ['estado'=>0]; | ||
|
||
$usuarios->update($estado); | ||
|
||
//Redirecionas para no bugear el jalar de datos con reddirect para recargar la vista totalmente | ||
return redirect('/Medico'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,4 +50,6 @@ public function persona() | |
{ | ||
return $this->belongsTo(Persona::class,'id_persona','id_persona'); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<x-layouts.app> | ||
|
||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.8.1/css/bootstrap-select.css"> | ||
|
||
<br> | ||
<div class="card"> | ||
<div class="card-header">Registro de un medico</div> | ||
<div class="card-body"> | ||
<form action="{{ url('Medico') }}" class="was-validated" method="post"> | ||
{!! csrf_field() !!} | ||
|
||
<label>Nombres</label></br> | ||
<input type="text" name="nombre_per" class="form-control" required></br> | ||
|
||
|
||
<label>Apellido Paterno</label></br> | ||
<input type="text" name="apellido_pa_per" class="form-control" required></br> | ||
|
||
|
||
<label>Apellido Materno</label></br> | ||
<input type="text" name="apellido_ma_per" class="form-control" required></br> | ||
|
||
|
||
<label>Carnet de Identidad</label></br> | ||
<input type="number" name="ci_per" pattern="[0-9]{1,10}" oninput="this.value = this.value.replace(/[^0-9.]+/g, '').slice(0,7) ;" class="form-control" required></br> | ||
|
||
|
||
<label>Celular</label></br> | ||
<input type="tel" name="cel_per" pattern="[0-9]{1,10}" oninput="this.value = this.value.replace(/[^0-9.]+/g, '').slice(0,8) ;" class="form-control" required></br> | ||
|
||
|
||
<label>Fecha Nacimiento</label></br> | ||
<input type="date" name="fecha_nac" class="form-control" required></br> | ||
|
||
|
||
<label for="">Especialidades</label><br> | ||
<select name="especialidades[]" class="selectpicker form-control" multiple > | ||
@foreach ( $especialidades as $especialidad ) | ||
<option value="{{$especialidad->id_especialidad}}" >{{$especialidad->nombre_especialidad}}</option> | ||
@endforeach | ||
</select><br> | ||
|
||
|
||
<label>Numero de Seguro</label></br> | ||
<input type="number" name="num_seguro" pattern="[0-9]{1,10}" oninput="this.value = this.value.replace(/[^0-9.]+/g, '').slice(0,11) ;" class="form-control" required></br> | ||
|
||
|
||
<label>Tipo de Sangre</label></br> | ||
<select class="form-control" required name="id_tipo_sangre"> | ||
@foreach($tipos_sangre as $tipo_sangre) | ||
<option value="{{ $tipo_sangre->id_tipo_sangre }}">{{$tipo_sangre->nombre_tipo_sangre}}</option> | ||
@endforeach | ||
</select> <br> | ||
|
||
|
||
|
||
<label>Es donante</label></br> | ||
<input type="text" name="donante" class="form-control" required></br> | ||
|
||
|
||
<label>Usuario</label></br> | ||
<input type="text" name="username" id="id" class="form-control" required></br> | ||
|
||
|
||
<label>Email</label></br> | ||
<input type="text" name="email" id="email" class="form-control" required></br> | ||
|
||
|
||
<label>Password</label></br> | ||
<input type="text" name="password" id="password" class="form-control" required></br> | ||
|
||
|
||
<input type="submit" value="Guardar" class="btn btn-success"></br> | ||
</form> | ||
|
||
</div> | ||
</div> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.8.1/js/bootstrap-select.js"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> | ||
<script> | ||
$('select').selectpicker(); | ||
</script> | ||
</x-layouts.app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<x-layouts.app> | ||
|
||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.8.1/css/bootstrap-select.css"> | ||
|
||
<br> | ||
<div class="card"> | ||
<div class="card-header">Actualizacion de un medico</div> | ||
<div class="card-body"> | ||
<form action="{{ url('Medico/' .$usuarios->id) }}" class="was-validated" method="post"> | ||
{!! csrf_field() !!} | ||
@method("PATCH") | ||
|
||
<label>Nombres</label></br> | ||
<input type="text" name="nombre_per" value="{{$usuarios->persona->nombre_per}}" class="form-control" required></br> | ||
|
||
|
||
<label>Apellido Paterno</label></br> | ||
<input type="text" name="apellido_pa_per" value="{{$usuarios->persona->apellido_pa_per}}" class="form-control" required></br> | ||
|
||
|
||
<label>Apellido Materno</label></br> | ||
<input type="text" name="apellido_ma_per" value="{{$usuarios->persona->apellido_ma_per}}" class="form-control" required></br> | ||
|
||
|
||
<label>Carnet de Identidad</label></br> | ||
<input type="number" name="ci_per" value="{{$usuarios->persona->ci_per}}" pattern="[0-9]{1,10}" oninput="this.value = this.value.replace(/[^0-9.]+/g, '').slice(0,7) ;" class="form-control" required></br> | ||
|
||
|
||
<label>Celular</label></br> | ||
<input type="tel" name="cel_per" value="{{$usuarios->persona->cel_per}}" pattern="[0-9]{1,10}" oninput="this.value = this.value.replace(/[^0-9.]+/g, '').slice(0,8) ;" class="form-control" required></br> | ||
|
||
|
||
<label>Fecha Nacimiento</label></br> | ||
<input type="datetime" name="fecha_nac" value="{{$usuarios->persona->fecha_nac}}" class="form-control" required></br> | ||
|
||
<label for="">Especialidades</label><br> | ||
<select name="especialidades[]" required class="selectpicker form-control" multiple > | ||
@foreach ( $especialidades as $especialidad ) | ||
<option value="{{$especialidad->id_especialidad}}" >{{$especialidad->nombre_especialidad}}</option> | ||
@endforeach | ||
</select><br> | ||
|
||
{{-- | ||
<label for="">Especialidades</label><br> | ||
<select name="especialidades[]" class="selectpicker form-control" multiple > | ||
@foreach ( $especialidades as $especialidad ) | ||
@foreach ($usuarios->persona->has_especialidad as $has) | ||
@if ($especialidad->id_especialidad == $has->id_especialidad) | ||
<option selected value="{{$especialidad->id_especialidad}}" >{{$especialidad->nombre_especialidad}}</option> | ||
@else | ||
<option value="{{$has->id_especialidad}}" >{{$especialidad->nombre_especialidad}}</option> | ||
@endif | ||
@endforeach | ||
{{-- <option value="{{$especialidad->id_especialidad}}" >{{$especialidad->nombre_especialidad}}</option> | ||
@endforeach | ||
{{-- </select><br> --}} | ||
|
||
|
||
<label>Numero de Seguro</label></br> | ||
<input type="number" name="num_seguro" value="{{$usuarios->persona->num_seguro}}" pattern="[0-9]{1,10}" oninput="this.value = this.value.replace(/[^0-9.]+/g, '').slice(0,11) ;" class="form-control" required></br> | ||
|
||
|
||
<label>Tipo de Sangre</label></br> | ||
<select class="form-control" required name="id_tipo_sangre"> | ||
@foreach($tipos_sangre as $tipo_sangre) | ||
@if ($tipo_sangre->id_tipo_sangre ==$usuarios->persona->id_tipo_sangre ) | ||
<option selected value="{{ $tipo_sangre->id_tipo_sangre }}">{{$tipo_sangre->nombre_tipo_sangre}}</option> | ||
@else | ||
<option value="{{ $tipo_sangre->id_tipo_sangre }}">{{$tipo_sangre->nombre_tipo_sangre}}</option> | ||
@endif | ||
|
||
|
||
|
||
|
||
@endforeach | ||
</select> <br> | ||
|
||
|
||
|
||
<label>Es donante</label></br> | ||
<input type="text" name="donante" value="{{$usuarios->persona->donante}}" class="form-control" required></br> | ||
|
||
|
||
<label>Usuario</label></br> | ||
<input type="text" value="{{$usuarios->username}}" name="username" id="id" class="form-control" required></br> | ||
|
||
|
||
<label>Email</label></br> | ||
<input type="text" value="{{$usuarios->email}}" name="email" id="email" class="form-control" required></br> | ||
|
||
|
||
<label>Password</label></br> | ||
<input type="text" name="password" placeholder="Solo en caso de cambio" id="password" class="form-control" ></br> | ||
|
||
|
||
<input type="submit" value="Guardar" class="btn btn-success"></br> | ||
</form> | ||
|
||
</div> | ||
</div> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.8.1/js/bootstrap-select.js"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> | ||
<script> | ||
$('select').selectpicker(); | ||
</script> | ||
</x-layouts.app> |
Oops, something went wrong.