Last active
September 20, 2017 05:53
-
-
Save tisuchi/e8df23b6ec9498a2640f5291e409fe98 to your computer and use it in GitHub Desktop.
Example of Laravel with() - tisuchi.com
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
<?php | |
$users = User::with('posts')->get(); | |
foreach($users as $user){ | |
$users->posts; // posts is already loaded and no additional DB query is run | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment