私はこのモデルを持っています:
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
を取得するにはどうすればよいですか? 多くのクエリが生成されるため、foreach には入れusers
たくありません。Game::find