Created
September 20, 2017 05:55
-
-
Save tisuchi/c860c01f5743d8f83f7b6d5a2f154fe6 to your computer and use it in GitHub Desktop.
Example of Laravel whereHas() - tisuchi.com
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
| <?php | |
| $users = User::whereHas('posts', function($q){ | |
| $q->where('created_at', '>=', '2015-01-01 00:00:00'); | |
| })->get(); | |
| // only users that have posts from this year are returned | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment