here's my database schema
and I have these models:
- Admin
- User
- Bet
- Match
- Team
I'm confused how to define the relationShip between matches
and teams
in models
here Is what I did till now...
User.php
public function bets()
{
return $this->hasMany('\App\Bet');
}
Bet.php
public function user()
{
return $this->belongsTo('\App\User');
}
public function match()
{
return $this->belongsTo('\App\Match');
}
Match.php
public function bets()
{
return $this->hasMany('\App\Bet');
}
//?????????????
Team.php
//?????????????
actually what I need Is the code that should be placed instead of
//???...
in both Team.php
and Match.php
so that I can easily do such things...
$team->matches();
$match->team1();
$match->team2();
thanks