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

Commit

Permalink
Merge branch 'main' of https://github.com/rats4final/citas
Browse files Browse the repository at this point in the history
  • Loading branch information
XSlayer67 committed Nov 24, 2022
2 parents 8a5c1c4 + d87a124 commit 31aa89f
Show file tree
Hide file tree
Showing 24 changed files with 402 additions and 109 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
9 changes: 7 additions & 2 deletions app/Http/Controllers/PersonaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -16,6 +18,7 @@ class PersonaController extends Controller
public function index()
{
$personas = Persona::get();
//return $personas;
return view('admin.Persona.index', compact('personas'));
}

Expand All @@ -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'));
}

/**
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/TipoRelacionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\Models\Persona;
use App\Models\TipoRelacion;
use Illuminate\Http\Request;

Expand All @@ -15,6 +16,7 @@ class TipoRelacionController extends Controller
public function index()
{
$TipoRelaciones = TipoRelacion::get();
//return $TipoRelaciones;
return view('admin.tipo_relacion.index', compact('TipoRelaciones'));
}

Expand All @@ -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'));
}

/**
Expand Down
83 changes: 83 additions & 0 deletions app/Http/Controllers/UsuarioController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

namespace App\Http\Controllers;

use App\Models\Usuario;
use Illuminate\Http\Request;
class UsuarioController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* 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(Usuario $usuario)
{
//
}
}
39 changes: 39 additions & 0 deletions app/Http/Requests/StorePersonaRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StorePersonaRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
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'
];
}
}
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');
}


}
11 changes: 10 additions & 1 deletion app/Models/Persona.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

}
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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions database/migrations/2022_09_22_152240_create_personas.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading

0 comments on commit 31aa89f

Please sign in to comment.