1

私はこのモデルを持っています:

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

4

1 に答える 1