MAKE A MEDICAL HISTORY SYSTEM

Published

I have a dilemma with my system, I have 2 controllers: patients and histories and I would like that when creating a history it would bring me the patient’s data and when saving that history the patient data with the history data is saved, someone help me use LARAVEL 8

migration table

class CreateHistorialsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('historials', function (Blueprint $table) {
            $table->id();
            $table->string('noexpediente',30);
            $table->string('ars',50);
            $table->string('nsspoliza',50);
            $table->string('resumenh',600);
            $table->string('estudios',600);
            $table->string('diagnostico',600);
            $table->string('procedimiento',600);
            $table->foreignId('id_pacientes')
            ->nullable()
            ->constrained('pacientes')
            ->cascadeOnUpdate()
            ->nullOnDelete();
            $table->timestamps();
        });
    }

Model Paciente

class Paciente extends Model

{

public function historials(){
    return $this->hasMany(historial::class,'id_pacientes', 'id');

}
}

Model Historial

class Historial extends Model

{

public function paciente(){return $this->belongsTo(paciente::class,'id_pacientes', 'id');


}

Source: Laravel

Published
Categorised as eloquent, laravel Tagged ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq