[Laravel4] Eloquent with的错觉

$categories = \Category::with(array('posts' => function ($query) {
    return $query->orderBy('created_at', 'desc')->take(10);
}))->get();

这样的相对语义化的写法很容易让人错误的以为会对每个分类下取10篇文章,而事实上是总共取10篇文章

QQ20140601-1.png

标签: none

添加新评论