0
特定の列を返すときに、この熱心な読み込みが機能しない理由が実際にはわかりません。 このコードは、このコードはlaravel eager loadingを使用して特定の列を選択しても動作しません。
$user=User::where('userName', $userName)
/*->with('points')*/
->with('examstaken')
->with('question')
->with(array('points'=>function($query){
$query->select('id','points');
}))
->get();
が平均動作しませんしません麦汁完璧
$user=User::where('userName', $userName)
->with('points')
->with('examstaken')
->with('question')
/*->with(array('points'=>function($query){
$query->select('id','points');
}))*/
->get();
最初のものは正しく値を返す一方で、「ポイント」は任意の値を返しません。..作品
何が問題なのですか?ここで
は私のユーザモデルにおける関係
public function points()
{
return $this->hasMany('App\Points','user_id');
}
おかげ..
あなたは関係に必要なキーを選択しないと、Eloquentはキーで親にマッチすることはできません – lagbox