Created
October 30, 2014 15:38
-
-
Save VaguelyOnline/57bab38f664f6531cb89 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class User { | |
| ... | |
| public function sites() { | |
| return $this->hasManyThrough('Site', 'Account'); | |
| } | |
| public function hasSite($site) { | |
| return $this->sites()->whereId($site->id)->count() != 0; | |
| } | |
| } | |
| // Elsewhere... | |
| // the following says that the 'id' clause in the were is ambiguous | |
| // (both models have an ID) - how can I cause my search to be constrained | |
| // to if the user is distantly related to the Site model with the given ID?! | |
| echo User::first()->hasSite(Site::first()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment