What you need is thid table: games_owners. This is a migration schema for it:
Schema::create('games_owners', function($table)
{
$table->increments('id');
$table->integer('user_id');
$table->integer('game_id');
$table->timestamps();
});
This would be your User model:
class User extends Eloquent
{
protected $guarded = array();
public static $rules = array();
// User belongsToMany Game
public function games()
{
return $this->belongsToMany('Game', 'games_owners', 'user_id');
}
}
And you game model:
class Game extends Eloquent
{
protected $guarded = array();
public static $rules = array();
// Game belongsToMany User
public function users()
{
return $this->belongsToMany('User', 'games_owners', 'game_id');
}
// Need to identify the owner user.
}
And then you'll be able to do things like this:
$user = User::find(1);
foreach($user->games as $game) {
echo $game->name;
}