Created
April 7, 2014 03:01
-
-
Save yfktn/10014244 to your computer and use it in GitHub Desktop.
Get all Posts that are belongs to a category ...
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
| /** | |
| * assume Post has belongsToMany relationship with Category, and Category has belongsToMany relationship with Post named posts | |
| * | |
| * we need to get all posts that belongs to a category ... | |
| */ | |
| $posts = Category::find($idCategory)->posts()->get(); | |
| // test | |
| foreach($posts as $p) | |
| { | |
| echo "{$p->id}\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment