Skip to content

Instantly share code, notes, and snippets.

@mattlanham
Created May 24, 2012 21:02
Show Gist options
  • Save mattlanham/2784224 to your computer and use it in GitHub Desktop.
Save mattlanham/2784224 to your computer and use it in GitHub Desktop.
######### 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