【发布时间】:2014-07-01 08:56:08
【问题描述】:
关于 Laravel 的 Eloquent ORM 的问题。我已经看过了,如果我错过了类似的问题,我深表歉意。
这些是我的模型:
类 Formatos 扩展 Eloquent { 公共函数 preguntas() { return $this->hasMany('\encuesta\Preguntas', 'fenc_id'); } } 类 Preguntas 扩展 Eloquent { 公共功能替代品() { 返回 $this->hasMany('\encuesta\Alternativas', 'alt_id'); } } 类 Alternativas 扩展 Eloquent{ }我的控制器的方法是:
public function show($id)
{
$formatos = encuesta\Formatos::find($id);
$preguntas = $formatos->preguntas;
$preguntas->alternativas;
return View::make(
'encuesta.formato.pregunta.show',
array('formatos' => $formatos)
);
}
我想要以下结果:
格式 form_id 表格信息 ... 孕妇 preg_id preg_descip ... 另类 alt_id alt_alterna ……我发现了,我没有很好的结果,请有人帮助我
【问题讨论】: