jake666 的个人博客 / 2 / 4 / 创建于 5年前 / 更新于 5年前 / 1 个改进
$posts = App\Post::withCount([ 'comments', 'comments as pending_comments_count' => function ($query) { $query->where('approved', false); } ])->get(); echo $posts[0]->comments_count; echo $posts[0]->pending_comments_count;
本作品采用《CC 协议》,转载必须注明作者和本文链接
常规操作。
不判空得到索引越界的骚操作
如果有多条数据的时候 不能sum 至少我不会,,比如sum(剩余数量)
@罪人 我还没找到,但是应该也可以
我要举报该,理由是:
推荐文章: