Skip to content

Instantly share code, notes, and snippets.

@kasparasg
Created March 18, 2016 09:10
Show Gist options
  • Save kasparasg/937127b4167c2ccc2d71 to your computer and use it in GitHub Desktop.
Save kasparasg/937127b4167c2ccc2d71 to your computer and use it in GitHub Desktop.
modelling
<?php
class League extends Model
{
public function teams()
{
return $this->hasMany(Team::class);
}
}
class Team extends Model
{
public function league()
{
return $this->belongsTo(League::class);
}
}
class Referee extends Model
{
public function match()
{
return $this->belongsTo(Match::class);
}
}
class Score extends Model
{
public function match()
{
return $this->belongsTo(Match::class)
}
}
class Match extends Model
{
public function referee()
{
return $this->hasOne(Referee::class);
}
public function homeTeam()
{
return $this->hasOne(Team::class);
}
public function awayTeam()
{
return $this->hasOne(Team::class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment