From 6ec0568d9c3284bf26b974d3b9a46c66c47d61da Mon Sep 17 00:00:00 2001 From: Marc15975 <91290441+Marc15975@users.noreply.github.com> Date: Sun, 11 Dec 2022 03:52:46 -0400 Subject: [PATCH] Citas - Especialidades --- app/Http/Controllers/CitasController.php | 21 +++--- .../Controllers/EspecialidadController.php | 52 ++++++++++++++ app/Models/Citas.php | 10 ++- app/Models/Especialidad.php | 17 +++++ app/Models/Persona.php | 5 ++ app/Models/Usario_has_especialidad.php | 21 ++++++ .../2022_09_26_151715_create_citas.php | 5 +- ...022_12_11_051408_create_especialidades.php | 29 ++++++++ ...1725_create_medicos_has_especialidades.php | 36 ++++++++++ resources/views/admin/Citas/create.blade.php | 72 ++++++++++++++++++- resources/views/admin/Citas/index.blade.php | 36 ++++++---- .../admin/Especialidades/create.blade.php | 41 +++++++++++ .../views/admin/Especialidades/edit.blade.php | 43 +++++++++++ .../admin/Especialidades/index.blade.php | 50 +++++++++++++ .../views/admin/Especialidades/show.blade.php | 17 +++++ .../views/admin/Historial/create.blade.php | 12 ++-- .../views/admin/Historial/edit.blade.php | 12 ++-- .../views/admin/Historial/index.blade.php | 6 +- resources/views/admin/Sedes/index.blade.php | 2 +- .../views/components/layouts/app.blade.php | 28 ++++---- .../views/components/layouts/footer.blade.php | 4 +- .../components/layouts/sidebar.blade.php | 16 ++--- routes/web.php | 4 ++ 23 files changed, 472 insertions(+), 67 deletions(-) create mode 100644 app/Http/Controllers/EspecialidadController.php create mode 100644 app/Models/Especialidad.php create mode 100644 app/Models/Usario_has_especialidad.php create mode 100644 database/migrations/2022_12_11_051408_create_especialidades.php create mode 100644 database/migrations/2022_12_11_051725_create_medicos_has_especialidades.php create mode 100644 resources/views/admin/Especialidades/create.blade.php create mode 100644 resources/views/admin/Especialidades/edit.blade.php create mode 100644 resources/views/admin/Especialidades/index.blade.php create mode 100644 resources/views/admin/Especialidades/show.blade.php diff --git a/app/Http/Controllers/CitasController.php b/app/Http/Controllers/CitasController.php index b2eda18..9323b09 100644 --- a/app/Http/Controllers/CitasController.php +++ b/app/Http/Controllers/CitasController.php @@ -4,6 +4,7 @@ use Illuminate\Http\Request; use App\Models\Citas; +use App\Models\Especialidad; use App\Models\User; class CitasController extends Controller @@ -11,28 +12,32 @@ class CitasController extends Controller public function index() { //$User =User::get(); - $Citas =Citas::with('users')->get(); + $Citas =Citas::with(['medico:id,id_persona','medico.persona:id_persona,nombre_per,apellido_pa_per,apellido_ma_per','paciente:id,id_persona','paciente.persona:id_persona,nombre_per,apellido_pa_per,apellido_ma_per'])->get(); - //return $Citas; return view ('admin.Citas.index',compact('Citas')); } public function create() { - $User = User::get(); - return view('admin.Citas.create'); + $Users = User::with(['persona:id_persona,nombre_per,apellido_pa_per,apellido_ma_per','persona.has_especialidad'])->get(); + + $Especialidades =Especialidad::all(); + + return view('admin.Citas.create',compact('Users','Especialidades')); } public function store(Request $request) { $request->validate([ - 'fecha_cita'=>['required'], 'detalles_cita'=>['required','max:50'] - ]); - $input = $request->all(); - Citas::create($input); + $Cita = $request->all(); + + $Nivel=['estado' => 1,'id_paciente'=> 1]; + $Cita= array_merge($Nivel, $Cita); + + Citas::create($Cita); return redirect('Citas')->with('flash_message', 'Citas Addedd!'); } diff --git a/app/Http/Controllers/EspecialidadController.php b/app/Http/Controllers/EspecialidadController.php new file mode 100644 index 0000000..22d30a6 --- /dev/null +++ b/app/Http/Controllers/EspecialidadController.php @@ -0,0 +1,52 @@ +belongsTo(User::class,'id'); + return $this->hasOne(User::class,'id','id_medico'); + } + public function paciente() + { + return $this->hasOne(User::class,'id' ,'id_paciente'); } } diff --git a/app/Models/Especialidad.php b/app/Models/Especialidad.php new file mode 100644 index 0000000..69919d9 --- /dev/null +++ b/app/Models/Especialidad.php @@ -0,0 +1,17 @@ +belongsTo(Persona::class,'id_pariente','id_persona'); } + public function has_especialidad() + { + return $this->hasMany(Usario_has_especialidad::class,'id_medico','id_persona'); + } + } diff --git a/app/Models/Usario_has_especialidad.php b/app/Models/Usario_has_especialidad.php new file mode 100644 index 0000000..67439c7 --- /dev/null +++ b/app/Models/Usario_has_especialidad.php @@ -0,0 +1,21 @@ +hasOne(Especialidad::class,'id_especialidad','id_especialidad'); + } +} diff --git a/database/migrations/2022_09_26_151715_create_citas.php b/database/migrations/2022_09_26_151715_create_citas.php index a031b81..8034790 100644 --- a/database/migrations/2022_09_26_151715_create_citas.php +++ b/database/migrations/2022_09_26_151715_create_citas.php @@ -17,9 +17,10 @@ public function up() $table->increments('id_cita'); $table->dateTime('fecha_cita'); $table->string('detalles_cita'); + $table->boolean('estado'); //TODO: arreglar el nullable - $table->Integer('id_secretaria')->unsigned()->nullable(); - $table->foreign('id_secretaria')->references('id')->on('users'); + $table->Integer('id_medico')->unsigned()->nullable(); + $table->foreign('id_medico')->references('id')->on('users'); $table->Integer('id_paciente')->unsigned()->nullable(); $table->foreign('id_paciente')->references('id')->on('users'); $table->timestamps(); diff --git a/database/migrations/2022_12_11_051408_create_especialidades.php b/database/migrations/2022_12_11_051408_create_especialidades.php new file mode 100644 index 0000000..7fab30c --- /dev/null +++ b/database/migrations/2022_12_11_051408_create_especialidades.php @@ -0,0 +1,29 @@ +increments('id_especialidad'); + $table->string('nombre_especialidad')->unique(); + $table->string('descripcion_especialidad'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('especialidades'); + } +}; diff --git a/database/migrations/2022_12_11_051725_create_medicos_has_especialidades.php b/database/migrations/2022_12_11_051725_create_medicos_has_especialidades.php new file mode 100644 index 0000000..48932ee --- /dev/null +++ b/database/migrations/2022_12_11_051725_create_medicos_has_especialidades.php @@ -0,0 +1,36 @@ +Integer('id_medico')->unsigned()->nullable(); + $table->foreign('id_medico')->references('id')->on('users'); + + + $table->Integer('id_especialidad')->unsigned()->nullable(); + $table->foreign('id_especialidad')->references('id_especialidad')->on('especialidades'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('medicos_has_especialidades'); + } +}; diff --git a/resources/views/admin/Citas/create.blade.php b/resources/views/admin/Citas/create.blade.php index 67a64fb..5021f4b 100644 --- a/resources/views/admin/Citas/create.blade.php +++ b/resources/views/admin/Citas/create.blade.php @@ -1,25 +1,91 @@ +
Crear Cita
{!! csrf_field() !!} +
+
+ + + +
+ +
+ + + +
+
+
-
+
@error('fecha_cita') {{$message}} @enderror + +

@error('detalles_cita') {{$message}} @enderror -
+ + + {{--

-
+ @error('detalles_cita') + {{$message}} + @enderror --}} +
+
diff --git a/resources/views/admin/Citas/index.blade.php b/resources/views/admin/Citas/index.blade.php index 0f4ed3a..a3aa67e 100644 --- a/resources/views/admin/Citas/index.blade.php +++ b/resources/views/admin/Citas/index.blade.php @@ -1,15 +1,15 @@ -
-
-
+ +
+

Citas

- Add New + Nueva Cita

@@ -18,22 +18,34 @@ # + Paciente + Medico Fecha Descripcion - Paciente + Estado + Acciones - @foreach($Citas as $item) + @foreach($Citas as $cita) {{ $loop->iteration }} - {{ $item->fecha_cita }} - {{ $item->detalles_cita }} - {{ $item->id_secretaria}} + {{ $cita->medico->persona->nombre_per ." ".$cita->medico->persona->apellido_pa_per ." ".$cita->medico->persona->apellido_ma_per }} + {{ $cita->paciente->persona->nombre_per ." ".$cita->paciente->persona->apellido_pa_per ." ".$cita->paciente->persona->apellido_ma_per }} + {{ $cita->fecha_cita }} + {{ $cita->detalles_cita }} + + @if ($cita->estado == 1) + Activa + + @else + Inactiva + @endif + - -
+ + @method('DELETE') {{ csrf_field() }} @@ -48,5 +60,5 @@
-
+ diff --git a/resources/views/admin/Especialidades/create.blade.php b/resources/views/admin/Especialidades/create.blade.php new file mode 100644 index 0000000..3170713 --- /dev/null +++ b/resources/views/admin/Especialidades/create.blade.php @@ -0,0 +1,41 @@ + +
+
Registro de Sedes
+
+ + + {!! csrf_field() !!} +
+ + @error('nombre_sede') +
  • {{$message}}
  • + @enderror + +
    +
    + + @error('direccion_sede') +
  • {{$message}}
  • + @enderror + +
    +
    + + @error('telefono_sede') +
  • {{$message}}
  • + @enderror
    + +
    + + +
    + + +
    +
    +
    diff --git a/resources/views/admin/Especialidades/edit.blade.php b/resources/views/admin/Especialidades/edit.blade.php new file mode 100644 index 0000000..39d5055 --- /dev/null +++ b/resources/views/admin/Especialidades/edit.blade.php @@ -0,0 +1,43 @@ + + +
    +
    Editar Sede
    +
    + +
    + {!! csrf_field() !!} + @method("PATCH") + + +
    + + @error('nombre_sede') +
  • {{$message}}
  • + @enderror
    +
    + + @error('direccion_sede') +
  • {{$message}}
  • + @enderror
    +
    + + @error('telefono_sede') +
  • {{$message}}
  • + @enderror + +
    +
    + + + +
    +
    + +
    +
    +
    diff --git a/resources/views/admin/Especialidades/index.blade.php b/resources/views/admin/Especialidades/index.blade.php new file mode 100644 index 0000000..5a5fd20 --- /dev/null +++ b/resources/views/admin/Especialidades/index.blade.php @@ -0,0 +1,50 @@ + +
    +
    +
    +
    +

    Especialidades

    +
    +
    + + Nueva especialidad + +
    +
    +
    + + + + + + + + + + + + @foreach ($Especialidades as $Especialidad) + + + + + + + + @endforeach + +
    #Nombre de la especialidadDescripcion de la especialidadAcciones
    {{ $loop->iteration }}{{ $Especialidad['nombre_especialidad'] }}{{ $Especialidad['descripcion_especialidad'] }} + + +
    + {{ method_field('DELETE') }} + {{ csrf_field() }} + +
    +
    +
    +
    +
    +
    +
    +
    diff --git a/resources/views/admin/Especialidades/show.blade.php b/resources/views/admin/Especialidades/show.blade.php new file mode 100644 index 0000000..798b4c3 --- /dev/null +++ b/resources/views/admin/Especialidades/show.blade.php @@ -0,0 +1,17 @@ + +
    +
    Datos de la Sede
    +
    + +
    +
    Nombre de la Sede : {{ $Sede->nombre_sede }}
    +

    Dirreccion de la sede : {{ $Sede->direccion_sede }}

    +

    Telefono de la sede : {{ $Sede->telefono_sede }}

    +

    Ciudad de la Sede: {{ $Sede->ciudad_sede }}

    +
    + + + +
    +
    +
    diff --git a/resources/views/admin/Historial/create.blade.php b/resources/views/admin/Historial/create.blade.php index b05d532..0e9f024 100644 --- a/resources/views/admin/Historial/create.blade.php +++ b/resources/views/admin/Historial/create.blade.php @@ -10,7 +10,7 @@ {{--

    --}} -
    @foreach ( $Users as $user) @@ -20,10 +20,10 @@ @endif @endforeach - +
    -
    @foreach ( $Sedes as $sede) @@ -32,10 +32,10 @@ @endforeach - +
    -
    @foreach ( $Users as $user) @@ -44,7 +44,7 @@ @endif @endforeach - +


    diff --git a/resources/views/admin/Historial/edit.blade.php b/resources/views/admin/Historial/edit.blade.php index 977d5be..d8da11c 100644 --- a/resources/views/admin/Historial/edit.blade.php +++ b/resources/views/admin/Historial/edit.blade.php @@ -9,7 +9,7 @@ @method("PATCH") -
    @foreach ( $Users as $user) @@ -22,9 +22,9 @@ @endif @endforeach - +
    -
    @foreach ( $Sedes as $sede) @@ -34,10 +34,10 @@ @endif @endforeach - +
    -
    @foreach ( $Users as $user) @@ -49,7 +49,7 @@ @endif @endif @endforeach - +


    diff --git a/resources/views/admin/Historial/index.blade.php b/resources/views/admin/Historial/index.blade.php index c88f0fd..689feac 100644 --- a/resources/views/admin/Historial/index.blade.php +++ b/resources/views/admin/Historial/index.blade.php @@ -2,7 +2,7 @@
    -
    +

    Historias

    @@ -34,8 +34,8 @@ {{ $Historia->fecha_historial}} {{ $Historia->detalles_historial }} - - + +
    {{ method_field('DELETE') }} {{ csrf_field() }} diff --git a/resources/views/admin/Sedes/index.blade.php b/resources/views/admin/Sedes/index.blade.php index ec94c41..d67d522 100644 --- a/resources/views/admin/Sedes/index.blade.php +++ b/resources/views/admin/Sedes/index.blade.php @@ -1,6 +1,6 @@
    -
    +

    Sedes

    diff --git a/resources/views/components/layouts/app.blade.php b/resources/views/components/layouts/app.blade.php index cf1557d..0d1ea38 100644 --- a/resources/views/components/layouts/app.blade.php +++ b/resources/views/components/layouts/app.blade.php @@ -16,11 +16,11 @@ Sidebar - - + - + +
    @@ -29,9 +29,9 @@
    -
    +
    - - - - - - + + + + + + - +