staudenmeir / belongs-to-through

Laravel Eloquent BelongsToThrough relationships
MIT License
1.17k stars 91 forks source link

Fixed Issue # 23 #25

Closed andreshg112 closed 7 years ago

andreshg112 commented 7 years ago

https://github.com/znck/belongs-to-through/issues/23

For the next situation:


preguntas:
  cod_preg: unsigned int, primary

eval_rel_preg:
  cod_erp : unsigned int, primary
  id_preg: unsigned int, foreign(preguntas)

eval_respuesta_estudiante:
  cod_ere: unsigned int, primary
  id_erp : unsigned int, foreign(eval_rel_preg)

We can relate the model EvaluacionRespuestaEstudiante (eval_respuesta_estudiante) to Pregunta (preguntas) through EvaluacionPregunta (eval_rel_preg).


public function pregunta()
    {
        public function pregunta()
        {
            return $this->belongsToThrough(
                Pregunta::class, [[EvaluacionPregunta::class, 'id_erp']], null, '', [Pregunta::class => 'id_preg']
            );
        }
    }
gracefullight commented 7 years ago

@znck merge please

znck commented 7 years ago

I'll do it tomorrow.