我正在尝试根据文档执行此查询,但返回错误 array_key_exists(): The first argument should be either a string or an integer
https://laravel.com/docs/5.8/queries#where-clauses
$imagessize = $galleryObj->photos->where([
['gallery_id','=', $gallery->id],
['delete','=',0],
])->sum('filesize');
该where
方法不接受数组,如果你想你应该使用whereIn方法:
该
whereIn
方法验证给定列的值是否包含在给定数组中:
例如:
users = DB::table('users')
->whereIn('id', [1, 2, 3])
->get();
这将返回 ID 为 1,2 和 3 的用户。
但在你的情况下,我认为你不需要那个。试试这个:
$imagessize = $galleryObj->photos->where('gallery_id',$gallery->id)->where('delete', 0)->sum('filesize');
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句