Created
May 24, 2012 21:02
-
-
Save mattlanham/2784224 to your computer and use it in GitHub Desktop.
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
######### account.php in /models | |
<?php | |
class Account extends Eloquent { | |
public function user() | |
{ | |
return $this->belongs_to('User'); | |
} | |
} | |
######### user.php in /models | |
<?php | |
class User extends Eloquent {} | |
######### collections.php in /controllers | |
<?php | |
class Collections_Controller extends Base_Controller { | |
public function action_index() | |
{ | |
foreach (Account::with('user')->get() as $account) | |
{ | |
echo $account->user->email; | |
} | |
return View::make('home.index'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment