Update a related model in belonsToMany (Laravel)

0

I need to update the information of a related table in two models I show the relationship in my entities, which has a form where more than one input is created and select which shows the information

Query Model

    class Consulta extends Model
    {
        protected $fillable = ['entrevista', 'examen_fisico', 'examenes_complementarios', 'diagnostico', 'tratamiento', 'enfermeria', 'fecha_consulta', 'observacion', 'trabajador_id', 'user_id', 'empresa_id', 'ausentismo_id', 'documentacion_id', 'consulta_reposo_id', 'consulta_motivo_id', 'consulta_tipo_id', 'nueva_cita'];

        public function prestacion_farmacia()
        {
            return $this->hasMany(PrestacionFarmacia::class);
        }
    }

Model PrestacionFarmacia

class PrestacionFarmacia extends Model
{
    protected $fillable = ['trabajador_id', 'empresa_id', 'user_id', 'prestacion_farmacia_droga_id', 'cantidad', 'consulta_id'];

    public function consulta()
    {
        return $this->belongsTo(Consulta::class);
    }

}
    
asked by vdjkelly 28.08.2018 в 20:15
source

0 answers