Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 codeigniter 后,我正在尝试 laravel 4。我对 Eloquent ORM 印象深刻,但我需要高级功能的实际示例。除了简单的实现之外,我找不到任何其他东西。例如,我需要获取按类别分组的帖子,例如
Games Post 1 Post 2 Movies Post 5 Post 7 .... ....
我如何使用 Eloquent 轻松做到这一点?有关范围和集合的示例将有很大帮助
foreach (Group::with('posts')->get() as $group) { $posts = $group->posts; foreach($posts as $post) { ... } }
您可能需要考虑有关急切加载的文档:
http://laravel.com/docs/eloquent