Created
July 10, 2014 19:11
-
-
Save cmbirk/e5b39ea77aee1e1c49aa to your computer and use it in GitHub Desktop.
Trying to combine multiple ManyToMany Relationships
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function sponsor() | |
{ | |
$sponsor = $this->belongsToMany('Group')->first(); | |
if(!$sponsor) { | |
return $this->belongsToMany('User'); | |
} | |
return $this->belongsToMany('Group'); | |
} | |
public function userSponsor() | |
{ | |
return $this->belongsToMany('User'); | |
} | |
public function groupSponsor() | |
{ | |
return $this->belongsToMany('Group'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simply trying to call sponsor() should return either the User sponsor or the Group sponsor. Currently it won't return a User sponsor.