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

Commit

Permalink
parecia mas facil maldita sea
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc15975 committed Dec 13, 2022
1 parent 959df75 commit 6917865
Show file tree
Hide file tree
Showing 8 changed files with 497 additions and 116 deletions.
99 changes: 99 additions & 0 deletions app/Http/Controllers/MedicoController.php
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');
}
}
49 changes: 7 additions & 42 deletions app/Http/Controllers/UsuarioController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,89 +10,54 @@
use Illuminate\Http\Request;
class UsuarioController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/

public function index()
{
$usuarios = user::with(['persona'])->get();
return view('admin.user.index', compact('usuarios'));
//return $usuario;
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/

public function create()
{
$personas = Persona::get();
$tipos_sangre = TipoSangre::get();
return view('admin.user.create', compact('tipos_sangre','personas'));
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
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];
$datos1 = ['rol'=>"2", 'estado'=>1, 'id_persona'=>$id->id_persona];
$datosUser = array_merge($datos, $datos1);
User::create($datosUser);
return redirect('/Usuario');


}

/**
* Display the specified resource.
*
* @param \App\Models\Usuario $usuario
* @return \Illuminate\Http\Response
*/

public function show(Usuario $usuario)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Usuario $usuario
* @return \Illuminate\Http\Response
*/

public function edit(Usuario $usuario)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Usuario $usuario
* @return \Illuminate\Http\Response
*/

public function update(Request $request, Usuario $usuario)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param \App\Models\Usuario $usuario
* @return \Illuminate\Http\Response
*/

public function destroy(Request $request, $usuario)
{
$input = $request->all();
Expand Down
2 changes: 2 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ public function persona()
{
return $this->belongsTo(Persona::class,'id_persona','id_persona');
}


}
85 changes: 85 additions & 0 deletions resources/views/admin/User_medico/create.blade.php
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>
109 changes: 109 additions & 0 deletions resources/views/admin/User_medico/edit.blade.php
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>
Loading

0 comments on commit 6917865

Please sign in to comment.