我有这个模型:
class Ownership extends Eloquent {
protected $table = 'game_user';
public function games() {
return $this->belongsToMany('Game');
}
public function type() {
return $this->belongsToMany('owntype');
}
}
Game和的模型Owntype很简单...extends Eloquent。这就是我提取数据的方式:
$games = Ownership::with('games','type')->where('user_id','=','1')->get();
从理论上讲,它有效。实际上,不是,因为它返回空games和owntype集合。这是它返回的内容:http: //paste.laravel.com/s94
如何获取games和users表格内容?我不想Game::find在 foreach 中,因为它会产生很多查询。