Skip to content

Instantly share code, notes, and snippets.

@DB-009
Created October 13, 2014 17:58
Show Gist options
  • Save DB-009/6fed92fa85bd4be43a9b to your computer and use it in GitHub Desktop.
Save DB-009/6fed92fa85bd4be43a9b to your computer and use it in GitHub Desktop.
Model Relationships
///EXHIBIT
public function medias()
{
return $this->hasMany('Media','parent_id','exhibit_id');
}
///ARTOBJ
public function medias()
{
return $this->hasMany('Media','parent_id','object_id');
}
public function artobjs()
{
return $this->belongsTo('ArtObj','parent_id','object_id');
}
public function exhibits()
{
return $this->belongsTo('Exhibit','parent_id','exhibit_id');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment