Created
January 30, 2015 04:41
-
-
Save appkr/02aac48f85871575b03a to your computer and use it in GitHub Desktop.
Laravel Sub-queries in Eager Loading
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 findByUsername($username) { | |
return User::with('statuses' => function($query) { | |
$query->latest(); | |
})->whereUsername($username)->first(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment